【发布时间】:2016-03-30 05:17:14
【问题描述】:
我的项目在 Xcode 7.3 上运行。
当我只是发出 GET 请求时,我得到了错误作为标题和信息:
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
错误信息:
此服务器的证书无效。您可能正在连接到一个伪装成“https://api.domain.com”的>服务器,这可能会使您的机密信息面临风险。
我搜索了解决方案,但没有一个有效。将这些添加到 info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
或 (我目前的设置)
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>https://api.domain.com:9002</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
我搜索过:
https://stackoverflow.com/a/32912578/291240
【问题讨论】:
-
只发生在 GET 方法或所有请求调用中。
-
GET 和 POST 一样的错误。
-
参考this post 可能会有帮助。