【iOS】App Transport Security

iOS9中新增App Transport Security(简称ATS)特性, 主要使到原来请求的时候用到的HTTP,都转向TLS1.2协议进行传输。这也意味着所有的HTTP协议都强制使用了HTTPS协议进行传输。

 

错误信息如下:

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.

 

解决方法:

1. 在 Filter 中搜索 Info.plist,选择 Info.plist 进行编辑,如图所示:

 

2. 按照上面提到的方式添加信息,正确的修改会看到下图这个样子,注意类型 NSAppTransportSecurity 为 Dictionary,NSAllowsArbitraryLoads 为 Boolean, 如下所示:

 

3. 注意⚠️,单元测试下面也有一个Info.plist,修改那个文件是没有作用的!

 

PS: 刚开始添加后可能会没效果,后来又删除重试了几次才行。

 

参考:

https://segmentfault.com/a/1190000002933776

http://my.oschina.net/vimfung/blog/494687

posted @ 2016-06-20 19:33  WriteOnRead  阅读(298)  评论(0编辑  收藏  举报