mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-01-31 00:00:03 +08:00
for capacitor, we need to find the certificates from main bundle
This commit is contained in:
@@ -155,10 +155,13 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
|
||||
@implementation SM_AFSecurityPolicy
|
||||
|
||||
+(BOOL) isRunningOnCapacitor {
|
||||
return NSClassFromString(@"CAPPlugin") != nil;
|
||||
}
|
||||
|
||||
+ (NSSet *)certificatesInBundle:(NSBundle *)bundle {
|
||||
NSString* assetDir = @"www";
|
||||
Class capacitorPluginClass = NSClassFromString(@"CAPPlugin");
|
||||
if(capacitorPluginClass != nil) {
|
||||
if([self isRunningOnCapacitor]) {
|
||||
// we are running on capacitor and its assets dir is 'public'
|
||||
assetDir = @"public";
|
||||
}
|
||||
@@ -178,7 +181,7 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
static NSSet *_defaultPinnedCertificates = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
NSBundle *bundle = [self isRunningOnCapacitor] ? [NSBundle mainBundle] : [NSBundle bundleForClass:[self class]];
|
||||
_defaultPinnedCertificates = [self certificatesInBundle:bundle];
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user