本文主要是介绍ios: 使用http进行通信(Transport Security has Blocked a cleartext HTTP),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
原文地址:http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http
问题:
What setting do i need to put in my info.plist
to enable http
mode as per the error message:
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.
解决:1、
See the developer forums: https://forums.developer.apple.com/thread/3544
Also this page: http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
For example you can add a specific domain like:
<key>NSAppTransportSecurity</key>
<dict><key>NSExceptionDomains</key><dict><key>yourserver.com</key><dict><!--Include to allow subdomains--><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:
<key>NSAppTransportSecurity</key>
<dict><!--Include to allow all connections (DANGER)--><key>NSAllowsArbitraryLoads</key><true/>
</dict>
Note:
info.plist
is an xml file so you can place this code more or less anywhere inside the file
2、
这篇关于ios: 使用http进行通信(Transport Security has Blocked a cleartext HTTP)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!