No solution for Transport Security?

回眸只為那壹抹淺笑 提交于 2019-12-08 04:21:42

问题


I have tried all the methods of here for solving the problem of: "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."

But if I try for example adding this in my plist file:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>www.myserver.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>

I get an error:"Unsupported URL", where in this case my link, looks like this:

let url:NSURL = NSURL(string: "www.myserver.com/jsonsignup.php")

But if I would use:

let url:NSURL = NSURL(string: "http://www.myserver.com/jsonsignup.php")

I would get the same error of Transport Security as mentioned above.

Any help?


回答1:


I had the same issue. I tried adding it to info.plist but it did not work for me either. So I tried this and it worked.

Click on your project name in the "Project Navigator" then click on info. And add it there. See highlighted.

Before I tried selecting the plist from my project navigator under supporting files and for some reason it did not work. The above should work for you.

Note: This will allow all connections.




回答2:


Are you using http://request ? then add following code in your .plist file.

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

I hope it's work for you.



来源:https://stackoverflow.com/questions/33011558/no-solution-for-transport-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!