iOS9 新特性ATS

2016-06-15  本文已影响25人  Onego

XCode7 新建的项目,要求使用HTTPS协议

HTTP+SSL/TLS+TCP = HTTPS

也就是说,服务需要提供HTTPS(TLS 1.2)的接口;

如果服务不改变,则需要在info.plist中加入下面的键值,用来信任所有HTTP服务器

<key>NSAllowsArbitraryLoads</key>

<true/>

<key>NSAppTransportSecurity</key>

<dict>

<!--Connect to anything (this is probably BAD)-->

<key>NSAllowsArbitraryLoads</key>

<true/>

</dict>

或者严谨的

<key>NSAppTransportSecurity</key>

<dict>

<key>NSExceptionDomains</key>

<dict>

<!--Include to allow subdomains-->

<key>NSIncludesSubdomains</key>

<true/>

<!--Include to allow insecure HTTP requests-->

<key>NSTemporaryExceptionAllowsInsecureHTTPLoads<key>

<true/>

<!--Include to specify minimum TLS version-->

<key>NSTemporaryExceptionMinimumTLSVersion</key>

<string>TLSv1.1</string>

</dict>

</dict>

</dict>

上一篇 下一篇

猜你喜欢

热点阅读