xCode 9-iOS 11:NSURLConnection-sendAsynchronousRequest失败 [英] xCode 9 - iOS 11: NSURLConnection - sendAsynchronousRequest fails

查看:102
本文介绍了xCode 9-iOS 11:NSURLConnection-sendAsynchronousRequest失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了最新版本的xCode(9.0 beta(9M136h)).

I just downloaded the latest version of xCode (9.0 beta (9M136h)).

但是,当我尝试向iOS 11模拟器中的服务器发出请求时(使用NSURLConnection sendAsynchronousRequest),会收到错误消息:

However, when I try to make a request to my server in iOS 11 simulator (Using NSURLConnection sendAsynchronousRequest), an error is received:

NSURLSession/NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9807) NSURLConnection完成,但出现错误-代码-1202

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9807) NSURLConnection finished with error - code -1202

NSError对象包含消息-@"NSLocalizedDescription":@此服务器的证书无效.您可能正在连接到冒充"***"的服务器,这可能会使您的机密信息受到威胁. "

NSError object contains the message - @"NSLocalizedDescription" : @"The certificate for this server is invalid. You might be connecting to a server that is pretending to be "***" which could put your confidential information at risk."

该plist包含:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

所以在这种情况下这不是问题(我想)

so it is not the problem in this case (I guess)

不用说它可以在iOS 10/9/8中运行

Needless to say that it is working in iOS 10/9/8

有什么建议吗?

提前谢谢!

推荐答案

对于所有在 iOS 11 中遇到此错误的人,请确保您使用的是有效(安全)证书您的服务器.

For all of you who get this error in iOS 11, please make sure you're working against valid (secured) certificate in your server.

在我们的情况下,证书不够严格.

In our case, the certificate wasn't strict enough.

我们的服务器人员集成了新的有效证书后,问题就消失了.

Once our server guy integrated new valid certificate, the problem has gone.

检查证书是否安全的一种方法是绕过浏览器中有问题的链接.

One way to check if the certificate is secured, is to past the problematic link in the browser.

结果,您可能会看到连接不安全:

As a result, you might see that the connection is not secured:

这篇关于xCode 9-iOS 11:NSURLConnection-sendAsynchronousRequest失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆