News
[20161221] 强制ATS没有按预先的在2017年1月1日执行,具体执行时间目前还没确定 资料:from Supporting App Transport Security
报错”kCFStreamErrorDomainSSL, -9824”
在访问http链接时报错”kCFStreamErrorDomainSSL, -9824”
Starting in iOS 9.0 and OS X v10.11, a new security feature called App Transport Security (ATS) is enabled by default for all HTTP connections made with NSURLSession. ATS requires that HTTP connections use HTTPS (RFC 2818).
从iOS9.0,OS X10.11开始,引入了一个新特性ATS,默认情况下所有的网络连接都是使用HTTPS协议进行传输
from :What’s New in iOS9.0-ATS
In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy.If you try to make a connection that doesn’t follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app’s Info.plist file.
The leaf server certificate must be signed with one of the following types of keys:
Rivest-Shamir-Adleman (RSA) key with a length of at least 2048 bits
Elliptic-Curve Cryptography (ECC) key with a size of at least 256 bits
证书要求:
1. 使用TLS1.2以上版本,并且
2. 站点使用支持forward secrecy(FS)协议的密码。
3. 证书密钥至少2048位,ECC密钥至少为256位
from: Requirements for Connecting Using ATS
支持FS协议的列表:
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
禁用ATS
现在苹果还没完全禁止http链接的访问,通过禁用ATS即可访问非https的网络访问。王巍的博客中提到:”WWDC 16 中,Apple 表示将继续在 iOS 10 和 macOS 10.12 里收紧对普通 HTTP 的访问限制。从 2017 年 1 月 1 日起,所有的新提交 app 默认是不允许使用 NSAllowsArbitraryLoads 来绕过 ATS 限制的”,也就是按苹果的说法,明年是不允许提交禁用ATS的应用,除了特殊的应用,比如浏览器之类的吧。
- Info.plist中添加App Transport Security Settings字典;
- 在该字典下添加Allow Arbitrary Loads属性,设为YES即可禁用ATS,任意访问非HTTPS的网络连接。
ps: 该字典下还有Exception Domains属性。将允许访问的非HTTPS连接添加到该列表中。建议使用Exception Domains而不是Allow Arbitrary Loads属性。从WWDC15提出ATS,到WWDC16继续加大对安全的管控,提高操作系统的安全性,网络安全的趋势势不可挡,没有特殊情况还是建议支持ATS,重视信息安全。
直接上图咯,具体的配置信息可查看App Transport Security Settings字典结构进行定制:
NSAppTransportSecurity
也就是App Transport Security Settings字典,它的结构如下所示,from apple:
NSAppTransportSecurity : Dictionary {
NSExceptionDomains : Dictionary {
<domain-name-string> : Dictionary {
NSIncludesSubdomains : Boolean
// Keys to describe your app’s intended network behavior for
// domains whose security attributes you control
NSExceptionAllowsInsecureHTTPLoads : Boolean
NSExceptionRequiresForwardSecrecy : Boolean
NSExceptionMinimumTLSVersion : String
// Keys to describe your app’s intended network behavior for
// domains whose security attributes you don't control
NSThirdPartyExceptionAllowsInsecureHTTPLoads : Boolean
NSThirdPartyExceptionRequiresForwardSecrecy : Boolean
NSThirdPartyExceptionMinimumTLSVersion : String
}
}
NSAllowsArbitraryLoads : Boolean
}
参考资料:
NSAppTransportSecurity-apple
关于iOS9中的App Transport Security相关说明及适配
iOS9 HTTP 不能正常使用的解决办法
关于 iOS 10 中 ATS 的问题-onevcat
iOS 9学习系列:如何使用ATS提高应用的安全性