具體錯誤如下:
Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made.
從網上看 就是在info.plist里邊添加 App Transport Security Settings的Allow Arbitrary Loads為YES 就可以解決問題然而還是不行
然后 在網絡請求代理里邊添加繞過證書方法如下:
//繞過證書
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]){
NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
completionHandler(NSURLSessionAuthChallengeUseCredential,credential);
}
}
還是報證書信任錯誤,要瘋了..接着又發現還需要加訪問地址白名單如圖就可以訪問了

