The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

前端 未结 21 1716
醉酒成梦
醉酒成梦 2020-11-22 11:37

I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0. Somehow it started giving me the Titled error

\"The resource could not be load

相关标签:
21条回答
  • 2020-11-22 12:18

    The resource could not be loaded because the App Transport Security policy requires the use of a secure connection working in Swift 4.03.

    Open your pList.info as source code and paste:

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    
    0 讨论(0)
  • 2020-11-22 12:19

    I have solved as plist file.

    Add a NSAppTransportSecurity : Dictionary.

    Add Subkey named " NSAllowsArbitraryLoads " as Boolean : YES

    0 讨论(0)
  • 2020-11-22 12:20

    Transport security is provided in iOS 9.0 or later, and in OS X v10.11 and later.

    So by default only https calls only allowed in apps. To turn off App Transport Security add following lines in info.plist file...

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

    For more info:
    https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33

    0 讨论(0)
  • 2020-11-22 12:20

    I have solved this issue in the case of a self hosted parse-server using a one year signed certificate rather than the option "NSAllowsArbitraryLoads"

    Parse Server as any node.js server presents a public https url that you have to specify. For instance:

    parse-server --appId --masterKey --publicServerURL https://your.public.url/some_nodejs

    Feel free to give a look to my configuration files

    0 讨论(0)
  • 2020-11-22 12:21

    If you are not a big fan of XML, then just add below tag in your plist file.

    0 讨论(0)
  • 2020-11-22 12:22

    From Apple documentation

    If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.

    To Bypass App Transport Security:

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

    To allow all insecure domains

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

    Read More: Configuring App Transport Security Exceptions in iOS 9 and OSX 10.11

    0 讨论(0)
提交回复
热议问题