首页 文章

App Transport Security已阻止明文HTTP(http://)资源加载,因为它不安全

提问于
浏览
2

App Transport Security已阻止明文HTTP(http://)资源加载,因为它不安全 . 可以通过应用程序的Info.plist文件配置临时例外 .

我有所有可能的解决方案,如:`NSAppTransportSecurity

<dict>

    <key>NSAllowsArbitraryLoads</key>

    <true/>

</dict>`

<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>

但仍面临同样的错误 .

1 回答

  • 5

    第一个设置不正确,这应该是:

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    

    第二个设置仅在 https 上有效但服务器不支持TLSv1.2时才有效

相关问题