=====================2016-01-29更新===========================html
最近作demo时,发现将https改为http方式略有小变ios
1. 没有改为http方式时输出的错误:api
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.安全
2.修改的Info.plist添加文字有变:网络
========================== 分割线 ==========刘成利 EMail: liu_cheng_li@qq.com============app
九月底,随着iOS9的推送升级和Xcode7的发布。因为新的iOS9中,网络请求默认方式为Https,一种比原来Http更安全的协议方式。单元测试
HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是SSL,所以加密的详细内容就须要SSL。测试
对于iOS开发人员来讲,项目开发中会产生网络访问失败。ui
输出错误信息:The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.加密
这是由于 iOS9引入了新特性App Transport Security (ATS)
。详情:苹果官网说明网址
新特性要求App内访问的网络必须使用HTTPS
协议。
可是如今公司的项目使用的是HTTP
协议,使用私有加密方式保证数据安全。如今也不能立刻改为HTTPS
协议传输。
在Info.plist中添加NSAppTransportSecurity
类型Dictionary
。
在NSAppTransportSecurity
下添加NSAllowsArbitraryLoads
类型Boolean
,值设为YES。