From 6f9bcd86af506cd8774eac1c1380e9b50eb72947 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 20 Apr 2015 19:47:24 -0500 Subject: [PATCH] #1306 - Moving api_mapbox_com.der to iOS Resources directory so that it can be accessed via GL Framework --- gyp/certificates.gypi | 2 +- platform/ios/MGLMapboxEvents.m | 18 +++++++++++++++--- .../ios/resources}/api_mapbox_com.der | Bin 3 files changed, 16 insertions(+), 4 deletions(-) rename {common => platform/ios/resources}/api_mapbox_com.der (100%) diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi index fdd818b8d..1d0c2acf8 100644 --- a/gyp/certificates.gypi +++ b/gyp/certificates.gypi @@ -4,7 +4,7 @@ 'type': 'none', 'hard_dependency': 1, 'copies': [{ - 'files': [ '../common/api_mapbox_com.der', '../common/ca-bundle.crt' ], + 'files': [ '../common/ca-bundle.crt' ], 'destination': '<(PRODUCT_DIR)' }], }, diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index e4b422fe8..90cddba45 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -649,8 +649,21 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { // Load Local Copy of Server's Public Key - // NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"b.ssl.fastly.net" ofType:@"der"]; - NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; + NSString *cerPath = nil; + NSArray *bundles = [NSBundle allFrameworks]; + for (int lc = 0; lc < bundles.count; lc++) { + NSBundle *b = [bundles objectAtIndex:lc]; + cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; + if (cerPath != nil) { + break; + } + } + if (cerPath == nil) { + NSLog(@"cerPath not found."); + return; + } + +// NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; NSData *localCertData = [NSData dataWithContentsOfFile:cerPath]; // Get Server's Public Key @@ -671,7 +684,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; } long numKeys = SecTrustGetCertificateCount(serverTrust); - NSLog(@"Number of certificaties presented: %ld", numKeys); BOOL found = false; for (int lc = 0; lc < numKeys; lc++) { diff --git a/common/api_mapbox_com.der b/platform/ios/resources/api_mapbox_com.der similarity index 100% rename from common/api_mapbox_com.der rename to platform/ios/resources/api_mapbox_com.der