Skip to content

Commit a7b48c7

Browse files
Remove custom certificate handling (#1635)
Certificate validation logic implemented in the Data SDK is a subject of transient errors, as it is implemented on top of deprecated APIs. Given that there's no handling of the custom certificates and logic corresponds to the default certificate handling in the iOS, custom implementation can be removed in the faviour of default handling. Relates-To: HERESDK-5806 Signed-off-by: Mykhailo Diachenko <[email protected]>
1 parent e4fdb37 commit a7b48c7

File tree

1 file changed

+5
-50
lines changed

1 file changed

+5
-50
lines changed

olp-cpp-sdk-core/src/http/ios/OLPHttpClient.mm

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -452,34 +452,14 @@ - (void)URLSession:(NSURLSession*)session
452452
"didReceiveChallenge failed - invalid session, "
453453
"task_id=%u",
454454
(unsigned int)dataTask.taskIdentifier);
455+
// Don't hang in non-happy path
456+
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge,
457+
nil);
455458
return;
456459
}
457460

458-
@autoreleasepool {
459-
if ([challenge.protectionSpace.authenticationMethod
460-
isEqualToString:NSURLAuthenticationMethodServerTrust]) {
461-
if (dataTask) {
462-
OLPHttpTask* httpTask =
463-
[self taskWithTaskDescription:dataTask.taskDescription];
464-
if (![httpTask isValid]) {
465-
return;
466-
}
467-
// TODO: Don't verify certificate is not implemented
468-
if (![self shouldTrustProtectionSpace:challenge.protectionSpace]) {
469-
completionHandler(
470-
NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
471-
return;
472-
}
473-
}
474-
475-
NSURLCredential* credential = [NSURLCredential
476-
credentialForTrust:challenge.protectionSpace.serverTrust];
477-
completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
478-
return;
479-
}
480-
481-
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
482-
}
461+
// Use iOS default certificate validation for all authentication challenges
462+
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
483463
}
484464

485465
- (void)URLSession:(NSURLSession*)session
@@ -533,31 +513,6 @@ - (void)URLSession:(NSURLSession*)session
533513
completionHandler(newRequest);
534514
}
535515

536-
// http://goo.gl/jmZ4Uv
537-
- (BOOL)shouldTrustProtectionSpace:(NSURLProtectionSpace*)protectionSpace {
538-
if (!protectionSpace) {
539-
return NO;
540-
}
541-
542-
SecTrustRef serverTrust = protectionSpace.serverTrust;
543-
if (!serverTrust) {
544-
return NO;
545-
}
546-
547-
// TODO - certificate paths are not supported!
548-
549-
// evaluate server trust against certificate
550-
SecTrustResultType trustResult = kSecTrustResultInvalid;
551-
OSStatus status = SecTrustEvaluate(serverTrust, &trustResult);
552-
553-
if (errSecSuccess != status) {
554-
return NO;
555-
}
556-
557-
return (trustResult == kSecTrustResultUnspecified ||
558-
trustResult == kSecTrustResultProceed);
559-
}
560-
561516
- (void)URLSession:(NSURLSession*)session
562517
downloadTask:(NSURLSessionTask*)dataTask
563518
didWriteData:(int64_t)bytesWritten

0 commit comments

Comments
 (0)