适配 https 报错NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)

适配https 是单项认证 一直报错NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
info.plist 配置
NSAppTransportSecurity

NSAllowsArbitraryLoads

NSExceptionDomains

https://111.111.11.1

NSIncludesSubdomains

NSExceptionMinimumTLSVersion
TLSv1.0



这是代码

  • (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
    {

    NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
    __block NSURLCredential *credential = nil;
    // 判断服务器返回的证书是否是服务器信任的
    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
    {
    credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
    if (credential)
    {
    disposition = NSURLSessionAuthChallengeUseCredential; // 使用证书
    }
    else
    {
    disposition = NSURLSessionAuthChallengePerformDefaultHandling; // 忽略证书 默认的做法
    }
    }
    else
    {
    disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; // 取消请求,忽略证书
    }
    if (completionHandler)// 安装证书
    {
    completionHandler(disposition, credential);
    }

}
一直报这个错误 不知道是服务端配置有问题还是 怎么 求解决办法