美文网首页
关于配置info.plist文件的https

关于配置info.plist文件的https

作者: 我是卖报滴小行家 | 来源:发表于2016-08-16 16:19 被阅读638次

在进行数据请求的时候,由于我依然用的http来请求,所以程序报错了:

错误报告:
2016-08-16 16:03:29.065 TheBlackListNet[3346:188988] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

2016-08-16 16:03:29.244 TheBlackListNet[3346:188843] Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x7f9268cc1500 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}, NSErrorFailingURLStringKey=http://XXX, NSErrorFailingURLKey=http://XXX, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}

出错原因:

这是因为在iOS9.0以后增加了APP Transport Security.将原来的Http转向了TLS1.2协议进行传输.这也就意味着原来的Http协议被强制使用了Https协议.

修正报错:打开info.plist文件,添加以下代码

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

-------------注意----------------------

但有时候“修改info.plist文件”依然不行,因为在你的Xcode - TARGETS - Info - Custom iOS Target Properties中可能依然没有添加上‘上述代码’。所以你要添加上,再运行久OK.

相关文章

网友评论

      本文标题:关于配置info.plist文件的https

      本文链接:https://www.haomeiwen.com/subject/htmpsttx.html