Last active
December 30, 2015 18:19
-
-
Save willyliu/7867219 to your computer and use it in GitHub Desktop.
Ignores SSL certificate checking.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler | |
{ | |
NSURLProtectionSpace * protectionSpace = challenge.protectionSpace; | |
if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { | |
SecTrustRef serverTrust = protectionSpace.serverTrust; | |
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust: serverTrust]); | |
} | |
else { | |
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment