iOS9种关于App Transport Security详细说明
来源:互联网 发布:c 二维数组输出 编辑:程序博客网 时间:2024/06/11 06:56
1、ios9更新介绍
因为有开发者账号在apple提供iOS 9beta 测试版,就马上更新iOS9,期间发现许多应用用不了,一打开就闪退或者更本连接不上网络。有种白老鼠的心情。这其中主要原因是iOS9系统的更新,开发的应用需要进行处理以适配iOS9。另外我也 更新了最新版的xcode以及osx ei cation,由其在新版本xcode下打开原来的代码,发现代码有许多地方报错,这个库不支持,这其中就需要对工程进行设置。要适配iOS9有两个大方向需要注意,一个是app transport security 另外一个需要注意的是app thinning ,这里谈一下app transport security 。
在新ios9 运行带网络请求的应用时会报错:The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
[20606:405724] 请求错误信息_: 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=0x7fc992c6e870 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
2、app transport securty说明
苹果一直致力于安全方面的考虑,通常使用ios系统比android系统更加安全也是因为ios开发中的一些特性。现ios9更加强调客户端与服务端连接和传输的安全性。
,app transport securty(ATS)苹果建议在网络请求中采用https协议,而且不是简单的遵循https协议,需要符合以下要求:
a、 要求Transport Layer security协议版本在TLS1.2以上
b、服务器的Cipers配置要求支持forward secrecy等
c、证书签名算法符合ATS要求
不遵循这些要求的服务器,会导致https服务在ios9中的连接依旧失效。
我们可以参照苹果提供的官方指南:App transport security Technote进行服务的升级配置以满足ATS要求
3、ATS详细配置
一般情况下,像一些个人开发者或者服务器暂时不具备https配置,以及引用其它外部链接并不支持https,苹果让我们可以自由灵活的配置以降低要求
开发者主要可以在应用的info.plist中添加NSAppTransportSecurity的相关配置,或者完全关闭https或者添加一些信任的地址。如下面配置:
a、设置是否允许http访问
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>NSAllowsArbitraryLoads 参数设置成true表示关闭https,支持所有的http请求。
b、配置某些网站支持http访问
<key>NSAppTransportSecurity></key><dict> <key>NSExceptionDomains<key>//配置白名单 <dict> <key>www.mywebsite.com</key> <dict> <key>NSExceptionAllowsInsecureHttpLoads</key>//运行该域名支持http <false/> </dict></dict></dict>
上面是配置NSAppTransportSecurity NSExcetionDomations参数,用来指定某个地址的服务配置,上面设置了www.mywebsite.com域名可以支持http服务
。另外我们还可以配置某个地址支持的https服务的版本以及禁用正向加密技术 forward secrecy:http://vincent.bernat.im/en/blog/2011-ssl-perfect-forward-secrecy.html
c、可以对某些网站的TSL版本及forward security支持进行设置
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>www.otherwebsite.com</key> <dict> <key>NSExceptionMinimumTLSVersion</key> <string>1.1<string/> <key>NSExceptionRequiresForwardSecrecy</key> <false/> </dict> </dict> </dict>
上面设置 www.otherwebsite.com 这个域名可支持最小的TSL版本为1.1同时禁用Forward security。
d、其它说明事项
另外一些 详细的配置参数如下:
NSAllowsArbitraryLoads – 设置true即支持所有HTTP请求
NSExceptionDomains – 添加白名单
NSExceptionMinimumTLSVersion – 白名单指定域名支持的TLS版本
NSExceptionRequiresForwardSecrecy – 白名单指定域名是否支持Forward Secrecy
NSExceptionAllowsInsecureHTTPLoads – 白名单指定域名禁用ATS
NSThirdPartyExceptionMinimumTLSVersion – 白名单指定第三方服务域名最低支持的TLS版本
NSThirdPartyExceptionRequiresForwardSecrecy – 白名单指定第三方服务域名是否支持Forward Secrecy
NSThirdPartyExceptionAllowsInsecureHTTPLoads – 白名单指定第三方域名禁用ATS
NSIncludesSubdomains
NSTemporaryExceptionAllowsInsecureHTTPLoads
NSTemporaryExceptionMinimumTLSVersion
NSTemporaryExceptionRequiresForwardSecrecy
上面的还有一些我们可以设置一些第三方域名,零时的设置,同样也是三个方面:一个是是可以设置禁用ATS,一个是可以设置服务域名支持的最低TLS版本,一个是指定第三方服务域名是否支持Forward security。
以上是关于ios9 App transport security 的详细说明。
参考文档:
https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/
- iOS9种关于App Transport Security详细说明
- 关于iOS9中的App Transport Security(ATS)相关说明及适配
- 关于iOS9中的App Transport Security相关说明及适配
- 关于iOS9中的App Transport Security相关说明及适配
- 关于iOS9中的App Transport Security相关说明及适配
- 关于iOS9中的App Transport Security相关说明及适配
- 关于iOS9中的App Transport Security相关说明及适配
- 关于iOS9中的App Transport Security相关说明及适配
- 关于iOS9中的App Transport Security相关说明及适配(更新于2016.7.1)
- iOS9 App Transport Security 如何应对?
- iOS9的ATS(App Transport Security)
- IOS-关于App Transport Security相关说明及适配
- iOS9中新增App Transport Security(简称ATS)特性,
- App Transport Security
- App Transport Security (ATS)
- App Transport Security(ATS)
- App Transport Security(ATS)
- App Transport Security(ATS)
- Android应用开发性能优化完全分析
- Spring + hibernate5 搭建web配置事务处理
- ios网络请求报错:the App Transport Security policy requires the use of a secure connection
- 面试笔试题知识点回顾
- AppleWatch真机调试问题:App Transport Security has blocked a cleartext HTTP(http://)resource load since...
- iOS9种关于App Transport Security详细说明
- 百度地图API学习总结
- 物理渲染-基于物理的光照模型
- 006.精度损失
- 算法之3--合并排序
- 详解Javascript 中的this指针
- 操作系统
- qduoj-xor
- dataGridView获取指定行的数据