From 6b2515d8c0f43cc06babbc1fcbd4cc15e9ef0a53 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Mon, 12 Aug 2013 00:15:49 -0400 Subject: [PATCH 1/2] When AFNetworking is in an embedded framework, load certificates from app bundle --- AFNetworking/AFURLConnectionOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 4498513..6de15a6 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -200,7 +200,7 @@ static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { static NSArray *_pinnedCertificates = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSBundle *bundle = [NSBundle mainBundle]; NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; From ad0d0cd46e5859050196a0b0984efd63b6bd0c28 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Mon, 12 Aug 2013 03:11:17 -0400 Subject: [PATCH 2/2] When AFNetworking is in an embedded framework, load certificates from all non-framework bundles --- AFNetworking/AFURLConnectionOperation.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 6de15a6..dbc59a1 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -200,13 +200,13 @@ static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { static NSArray *_pinnedCertificates = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - NSBundle *bundle = [NSBundle mainBundle]; - NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; - - NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; - for (NSString *path in paths) { - NSData *certificateData = [NSData dataWithContentsOfFile:path]; - [certificates addObject:certificateData]; + NSMutableArray *certificates = [NSMutableArray array]; + for (NSBundle *bundle in [NSBundle allBundles]) { + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } } _pinnedCertificates = [[NSArray alloc] initWithArray:certificates];