WWDC 2016開發者大會上,蘋果宣布:2017/1/1開始,所有App store內的App必須啟用 App Transport Security(ATS)安全功能,所有App網絡請求啟用https。
當然在這期間(2017/1/1之前)還是可以通過對info.plist設置,繼續使用http進行網絡請求。
在iOS9中新增ATS特性, 主要使到原來請求的時候用到的HTTP,都轉向TLS1.2協議進行傳輸。這也意味着所有的HTTP協議都強制使用了HTTPS協議進行傳輸。
打開info.plist文件,新增以下字典
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
介紹一下對於ATS的一些需求:
1、必須基於TSL 1.2版本協議 (The protocol Transport Security Layer (TLS) must be at least version 1.2.)
2、連接的加密方式要提供Provide Forward Secrecy【PFS】 (Connection ciphers are limited to those that provide forward secrecy)
3、證書至少要使用一個SHA256的指紋與任一個2048位或者更高位的RSA密鑰,或者是256位或者更高位的ECC密鑰 (Certificates must use at least an SHA256 fingerprint with either a 2048 bit or greater RSA key, or a 256 bit or greater Elliptic-Curve (ECC) key)
PFS(perfect forward secrecy),中文可叫做完全前向保密。要求一個密鑰只能訪問由它所保護的數據;用來產生密鑰的元素一次一換,不能再產生其他的密鑰;一個密鑰被破解,並不影響其他密鑰的安全性。