App Transport Security Has Blocked a Cleartext Http Resource

Transport security has blocked a cleartext HTTP

If you are using Xcode 8.0+ and Swift 2.2+ or even Objective C:

Sample Image

If you want to allow HTTP connections to any site, you can use this keys:

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

If you know which domains you will connect to add:

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>

App Transport Security has blocked a cleartext HTTP resource

You need to correct it like this:

Sample Image

To make it easier, this is the correct xml in the info.plist

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>

change the localhost to your actual server

Check the table for NSAppTransportSecurity options

If you want to all communications with any domain, you can do this:

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

However, you should use the latest just in the developing phase.

App transport Security load Error even after adding it

You should add Allow Arbitrary Loads inside App Transport Security Settings dictionary, like this:

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

Sample Image

iOS swift: App Transport Security has blocked a cleartext HTTP (http://) resource

Seems to be that you are right, that SWAPI supports only the http protocol.

To support also an unsecure connection do this:

  1. Open the info.plist file
  2. Add the Key called App Transport Security Settings as Dictionary (Dictionary should be the default type)
  3. Add the Subkey called Allow Arbitrary Loads as Boolean (Boolean should be the default type). Set it to YES

See also the Screenshot:

Sample Image

App Transport Security has blocked a cleartext HTTP XCode 7.1

Use NSTemporaryExceptionAllowsInsecureHTTPLoads instead of NSAllowsArbitraryLoads

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>myDomain.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>anotherDomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>

App access blocked due to App Transport Security has blocked a cleartext HTTP and done almost everything

You need to add this also Allows Arbitrary Loads

Sample Image



Related Topics



Leave a reply



Submit