App Transport Security (ATS)
2015-08-05 18:05
471 查看
iOS9中,对C/S应用影响最大的应该是ATS这个功能了吧,所有的HTTP(S)连接都会有波及。这个功能是什么意思呢?简单来说就是Apple强制所有HTTP服务都需要用HTTP(S)来连接,要支持TLSv1.2 SSL。
但请注意,这个新的特性只是能触发,必须要用Xcode7来编译App。换句话说,如果是用Xcode6.x的Xcode编译的App,即使支持iOS9也不会有影响。
当然,如果我们的服务器来不及支持HTTPs,那我们需要修改info.plist来申明哪些服务是不支持的,在info.plist中加多一个key如下:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</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>
如果所有的服务都不支持HTTPs,也可以直接申明不支持,在info.plist中加多一个key如下:
<key>NSAppTransportSecurity</key>
<dict>
<!--Connect to anything (this is probably BAD)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>当然,Apple不建议这么做!
请参考:App Transport Security Technote
同时看到篇很不错的文章:iOS9AdaptationTips
但请注意,这个新的特性只是能触发,必须要用Xcode7来编译App。换句话说,如果是用Xcode6.x的Xcode编译的App,即使支持iOS9也不会有影响。
当然,如果我们的服务器来不及支持HTTPs,那我们需要修改info.plist来申明哪些服务是不支持的,在info.plist中加多一个key如下:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</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>
如果所有的服务都不支持HTTPs,也可以直接申明不支持,在info.plist中加多一个key如下:
<key>NSAppTransportSecurity</key>
<dict>
<!--Connect to anything (this is probably BAD)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>当然,Apple不建议这么做!
请参考:App Transport Security Technote
同时看到篇很不错的文章:iOS9AdaptationTips
相关文章推荐
- 苹果公司正式发布iOS9 beta3
- AddressBookUI Framework in iOS9 beta4
- AFNetWorking 在 IOS9 请求数据失败解决方案
- Storyboard Reference
- App Transport Security
- iOS8统一的系统提示控件——UIAlertController
- iOS9系列专题五——全新的联系人与联系人UI框架
- iOS9系列专题四——APP传输安全
- iOS9系列专题三——应用瘦身
- iOS9系列专题二——全新的搜索功能api
- iOS 9应用开发教程之ios9中实现按钮的响应
- iOS安全系列之一:HTTPS
- iOS 9适配技巧(更新版)
- iOS 9使用HTTP(App Transport Security问题)
- iOS9 http设置时遇到的问题
- iOS9 Notifications and Text Input
- iOS9Http请求失败
- iOS 9以上,状态栏改白色
- Xcode7 真机测试设置
- iOS9的新特性