iOS ---------NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)

遇到此问题的解决办法:

使用中的didReceiveChallenge方法,方法中的代码如下:

- (void)URLSession:(NSURLSession *)sessiondidReceiveChallenge:(NSURLAuthenticationChallenge *)challenge

completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition,NSURLCredential * __nullable credential))completionHandler

{

NSLog(@"didReceiveChallenge");

completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredentialcredentialForTrust:challenge.protectionSpace.serverTrust]);

}

当然,info.plist里面也要加上下面这段:

NSAppTransportSecurity

NSAllowsArbitraryLoads

你可能感兴趣的:(iOS ---------NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813))