Transport Security Has Blocked a Cleartext Http

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 Xcode7.1

Open Info.plist and change that text with NSAllowsArbitraryLoads and your issue will be resolved.

Or open Info.plist file in Source Code mode and replace the following lines:

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


Related Topics



Leave a reply



Submit