From cde989093baaf8fac2c4287fd462cf419abf1052 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 27 Apr 2015 12:22:05 -0400 Subject: [PATCH] #1307 - Adding digicert to sdks and ssl handshaking check --- platform/ios/MGLMapboxEvents.m | 22 ++++++++++++++++++ .../ios/resources/api_mapbox_com-digicert.der | Bin 0 -> 2077 bytes 2 files changed, 22 insertions(+) create mode 100644 platform/ios/resources/api_mapbox_com-digicert.der diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index b32e13988..42c1dc07c 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -74,6 +74,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; @property (atomic) NSDateFormatter *rfc3339DateFormatter; @property (atomic) CGFloat scale; @property (atomic) NSURLSession *session; +@property (atomic) NSData *digicertCert; @property (atomic) NSData *geoTrustCert; @@ -145,6 +146,12 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; _geoTrustCert = [NSData dataWithContentsOfFile:cerPath]; } + cerPath = nil; + cerPath = [[NSBundle bundleForClass:[MGLMapboxEvents class]] pathForResource:@"api_mapbox_com-digicert" ofType:@"der"]; + if (cerPath != nil) { + _digicertCert = [NSData dataWithContentsOfFile:cerPath]; + } + // Events Control _eventQueue = [[NSMutableArray alloc] init]; _flushAt = 20; @@ -679,6 +686,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; long numKeys = SecTrustGetCertificateCount(serverTrust); BOOL found = false; + // Try GeoTrust Cert First for (int lc = 0; lc < numKeys; lc++) { SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); @@ -692,6 +700,20 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; } } + // Fallback to Digicert Cert + for (int lc = 0; lc < numKeys; lc++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); + NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); + + // Compare Remote Key With Local Version + if ([remoteCertificateData isEqualToData:_digicertCert]) { + // Found the certificate; continue connecting + completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); + found = true; + break; + } + } + if (!found) { // The certificate wasn't found in the certificate chain; cancel the connection completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); diff --git a/platform/ios/resources/api_mapbox_com-digicert.der b/platform/ios/resources/api_mapbox_com-digicert.der new file mode 100644 index 0000000000000000000000000000000000000000..d84cee390869435b9b0672232b5597f347b67faf GIT binary patch literal 2077 zcma)7Yfuwc6yDuz0to~H8v&I^6tp5G+zlWvm64#*3JRhi_!t8TAsRwVLV^k+Tg3;W zw#Z-|R0PBq)QYGm7=-ctKoq5eqG<75-++RMb~g$I@ke(iGkd;s?m6H6?%pqeFdhmB zBRHRizzD)&??_&K^*|G^`OTg;?T(vf0ycv=HX|tGJsXBi=nzQ4O#qWYn~gFsWOg_{ z1YlIa!b}5YQkhVq((ry##NtDNH3ges9Gy{%tl4(U632%l8Op7+D9ezr5RjYEJo!$HPVL zF=b{;bJUJ|1Mv3=-ANs3#I4Z3qjc-ihb{NlHs7V+p6>nh(1~o;u{(-Zs3WeVd6)g= z4$0_srzFDMK)VMGkM7oSb}`=u&o$a`!8)X8j^F1toU^~6s`^Hu5}vz_b8xdFB-Q_N zWc1DsW_M{#P1pV~tVHS7bj+s_MGl7I`i z8jaG|%`H|XcOP)u-PG|SfvZI8sy5tYS1HaXYX-0K_&=)xsIffM5BLBt26JIX5S-B? zM_@1(jOitZz*e>t7d1)dTjy~ThK7UmwY{Y-QYnSE7A z#+2U8iYQN04=8l&^)$-TdL8XQL;K=q!bzkE8iQNdVU*|ype|_|gJp21#-#{~pah&q z{uaYBNDCDmXKpUHnZsREi4|OyDp}(_x1wFcTPj+0SIo|{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