ios: 使用http进行通信(Transport Security has Blocked a cleartext HTTP)

来源:互联网 发布:京东泄密 数据 编辑:程序博客网 时间:2024/06/16 15:26

原文地址: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、


0 0