mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-01-31 00:00:03 +08:00
use correct asset name for ios platform if we are running capacitor
This commit is contained in:
@@ -156,15 +156,14 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
@implementation SM_AFSecurityPolicy
|
||||
|
||||
+ (NSSet *)certificatesInBundle:(NSBundle *)bundle {
|
||||
NSArray* paths = @[];
|
||||
for(NSString* dir in @[@"www", @"public"]) {
|
||||
NSArray* certificatePaths = [bundle pathsForResourcesOfType:@"cer" inDirectory: [NSString stringWithFormat:@"%@/certificates", dir]];
|
||||
if(certificatePaths.count > 0) {
|
||||
paths = certificatePaths;
|
||||
break;
|
||||
}
|
||||
NSString* assetDir = @"www";
|
||||
Class capacitorPluginClass = NSClassFromString(@"CAPPlugin");
|
||||
if(capacitorPluginClass != nil) {
|
||||
// we are running on capacitor and its assets dir is 'public'
|
||||
assetDir = @"public";
|
||||
}
|
||||
|
||||
NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory: [NSString stringWithFormat:@"%@/certificates", assetDir]];
|
||||
NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]];
|
||||
|
||||
for (NSString *path in paths) {
|
||||
@@ -179,7 +178,7 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
static NSSet *_defaultPinnedCertificates = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
_defaultPinnedCertificates = [self certificatesInBundle:bundle];
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user