afnetworking

在iOS 9中 苹果将原http协议改成了https协议 使用 TLS1.2 SSL加密请求数据,所以我们不能直接请求http协议下的数据了。

解决办法也很简单,用编辑器打开工程文件下的Info.plist文件添加下面的代码就可以了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>

<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>

The lazy option is:

1
2
3
4
5
6
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>