By Jeef


2015-07-06 20:10:21 8 Comments

What setting do I need to put in my info.plist to enable HTTP mode as per the following error message?

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.

Xcode

Assume that my domain is example.com.

24 comments

@Faris 2019-01-16 10:56:36

In swift 4 and xocde 10 is change the NSAllowsArbitraryLoads to Allow Arbitrary Loads. so it is going to be look like this :

<key>App Transport Security Settings</key>
<dict>
     <key>Allow Arbitrary Loads</key><true/>
</dict>

@Julian Król 2015-09-01 12:10:08

This is a quick workaround (but not recommended) to add this in the plist:

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

Which means (according to Apple's documentation):

NSAllowsArbitraryLoads
A Boolean value used to disable App Transport Security for any domains not listed in the NSExceptionDomains dictionary. Listed domains use the settings specified for that domain.

The default value of NO requires the default App Transport Security behaviour for all connections.

I really recommend links:

which help me understand reasons and all the implications.

The XML (in file Info.plist) below will:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <false/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>PAGE_FOR_WHICH_SETTINGS_YOU_WANT_TO_OVERRIDE</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

disallow arbitrary calls for all pages, but for PAGE_FOR_WHICH_SETTINGS_YOU_WANT_TO_OVERRIDE will allow that connections use the HTTP protocol.

To the XML above you can add:

<key>NSIncludesSubdomains</key>
<true/>

if you want to allow insecure connections for the subdomains of the specified address.

The best approach is to block all arbitrary loads (set to false) and add exceptions to allow only addresses we know are fine.

For interested readers

2018 Update:

Apple is not recommending switching this off - more information can be found in 207 session WWDC 2018 with more things explained in regards to security

Leaving the original answer for historic reasons and development phase

@Sound Blaster 2015-09-14 08:37:04

NSAllowsArbitraryLoads must be false

@Julian Król 2015-09-21 09:20:33

@SoundBlaster for what case and what you see wrong in my answer to down vote?

@amit gupta 2015-09-22 10:19:43

by adding in plist(NSAppTransportSecurity NSAllowsArbitraryLoads), all web service working fine except one web service one web service return internal server error (500) in iOS 9 but working fine in iOS8 or later

@Julian Król 2015-10-07 07:36:03

@SoundBlaster made a change, now you shouldn't have objections :)

@Agent Zebra 2016-08-10 19:11:55

Thanks, how do you actually add the <key>NSIncludesSubdomains</key> <true/> ? Does every setting have to be surrounded by <dict>? how do you edit this damn plist file? What's the formatting? :D Thank you.

@Alekseev Vladimir 2017-10-09 10:44:59

For those who came here trying to find the reason why their WKWebView is always white and loads nothing (exactly as described here how do I get WKWebView to work in swift and for an macOS App) :

If all the rocket science above does not work for you check the obvious: the sandbox settings

sandbox settings]

Being new to swift and cocoa, but pretty experienced in programming I've spend about 20 hours to find this solution. None of dozens hipster-iOS-tutorials nor apple keynotes – nothing mentions this small checkbox.

@Brecht Machiels 2018-04-30 11:05:18

Oh my god, thank you so much! You saved me the same 20 hour search!

@shim 2018-07-20 14:42:14

not seeing that section in the Capabilities section of the target (Xcode 9.4.1)

@Anit Kumar 2016-10-28 07:06:57

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

Enter image description here

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

@jww 2017-06-06 04:04:53

Why is NSAllowsArbitraryLoads set to true? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@ThinkDigital 2018-07-21 00:00:24

@jww This is the purpose of this post. The site I need to connect to to play audio doesn't use HTTPS yet and I'm not trying to wait.

@Freek Sanders 2019-03-12 14:45:45

This will not work in iOS 10.0+ or MacOS 10.12+ It actually says to allow all arbitrary loads EXCEPT those mentioned (example.com). Thus it would do the reverse of what is desired. NSAllowsArbirtraryLoads should be set to false here. more info: Apple docs

@Sound Blaster 2015-09-14 08:36:37

This was tested and was working on iOS 9 GM seed - this is the configuration to allow a specific domain to use HTTP instead of HTTPS:

<key>NSAppTransportSecurity</key>
<dict>
      <key>NSAllowsArbitraryLoads</key> 
      <false/>
       <key>NSExceptionDomains</key>
       <dict>
            <key>example.com</key> <!--Include your domain at this line -->
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
            </dict>
       </dict>
</dict>

NSAllowsArbitraryLoads must be false, because it disallows all insecure connection, but the exceptions list allows connection to some domains without HTTPS.

@DiscDev 2015-09-16 17:18:02

THIS should be marked as the answer. Tested and working on iOS 9 GM seed to allow a specific domain to use http without taking the "lazy" way and completely opening your app up.

@JMStudios.jrichardson 2015-09-20 01:33:53

How do I add this to my info.plist?

@JMStudios.jrichardson 2015-09-20 03:17:44

If you open info.plist with sublime text app then you get the xml

@KMC 2015-10-05 16:57:49

Ok I added that entry to my info.plist and I'm still getting this error - " App 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."

@mikemike396 2015-10-16 13:22:59

Thank you this works! Looks like the NSAllowsArbitraryLoads = False is required for the NSExceptionDomains to work.

@atrebbi 2015-10-25 09:49:06

does not work on 9.1 tvOS , tryng to open this link NSURL *videourl = [NSURL URLWithString:@"http://<user>:<password>@mysubdomain.myserve‌​r.com/cam1/video.cgi‌​"];

@funct7 2015-12-02 02:30:29

@user30646 Did you change the domain? yourdomain.com should be changed to "whatever your domain is"

@Roman Shapovalov 2016-09-22 13:51:28

What if I don’t have a domain name and just use an IP address?

@Sound Blaster 2016-09-27 09:39:52

@RomanShapovalov Using IP addresses is strongly not recommended because all iOS apps must conform IPv6, see Apple Docs about this

@tpankake 2016-10-13 17:16:28

@RomanShapovalov if you must use an IP address, try adding .xip.io to the end of the IP address and add xip.io to your NSExceptionDomains. See xip.io. I connect directly to IP when developing (but not release) and this works great for me.

@adamF 2017-09-09 05:07:21

this should be the correct answer. The accepted answer sets NSAllowsArbitraryLoads to true, which allows urls through from any domain. It should be set to false

@Chucky 2018-02-17 17:08:34

Wasn't working for me until I realised I had put it in the wrong info.plist in my test project. Make sure you put it in the right one!

@Cons Bulaquena 2018-03-12 16:17:54

@SoundBlaster Where do you put this code?

@Hemang 2018-04-25 06:22:52

@ConsBulaquena, it will go inside your Info.plist file.

@Nurlan 2017-08-14 06:12:50

Using NSExceptionDomains may not apply an effect simultaneously due to target site may load resources (e.g. js files) from external domains over http. It can be resolved by adding these external domains to NSExceptionDomains as well.

To inspect which resources cannot be loaded try to use Remote debugging. Here is a tutorial: http://geeklearning.io/apache-cordova-and-remote-debugging-on-ios/

@gnasher729 2016-04-17 23:54:11

According to Apple, generally disabling ATS will lead to app rejection, unless you have a good reason to do so. Even then, you should add exceptions for domains that you can access safely.

Apple has an excellent tool that tells you exactly what settings to use: In Terminal, enter

/usr/bin/nscurl --ats-diagnostics --verbose https://www.example.com/whatever

and nscurl will check whether this request fails, and then try a variety of settings and tell you exactly which one passes, and what to do. For example, for some third-party URL that I visit, this command told me that this dictionary passes:

{
    NSExceptionDomains = {
        "www.example.com" = {
            NSExceptionRequiresForwardSecrecy = false;
        };
    };
}

To distinguish between your own sites and third-party sites that are out of your control, use, for example, the key NSThirdPartyExceptionRequiresForwardSecrecy.

@damithH 2017-01-10 09:11:57

its great tool to check before actually test with the application. save time. but any resource to read to understand the out put of this command.

@Chris Prince 2017-06-26 04:08:19

Interesting tool. In my case it overstates things though. It lists three keys including NSExceptionAllowsInsecureHTTPLoads = true;, but it turns out that one's not needed.

@whyceewhite 2015-09-21 17:56:42

For those of you who want a more context on why this is happening, in addition to how to fix it, then read below.

With the introduction of iOS 9, to improve the security of connections between an app and web services, secure connections between an app and its web service must follow best practices. The best practices behavior is enforced by the App Transport Security to:

  • prevent accidental disclosure, and
  • provide a default behavior that is secure.

As explained in the App Transport Security Technote, when communicating with your web service, App Transport Security now has the following requirements and behavior:

  • The server must support at least Transport Layer Security (TLS) protocol version 1.2.
  • Connection ciphers are limited to those that provide forward secrecy (see the list of ciphers below.)
  • Certificates must be signed using a SHA256 or better signature hash algorithm, with either a 2048 bit or greater RSA key or a 256 bit or greater Elliptic-Curve (ECC) key.
  • Invalid certificates result in a hard failure and no connection.

In other words, your web service request should: a.) use HTTPS and b.) be encrypted using TLS v1.2 with forward secrecy.

However, as was mentioned in other posts, you can override this new behavior from App Transport Security by specifying the insecure domain in the Info.plist of your app.


To override, you will need to add the NSAppTransportSecurity > NSExceptionDomains dictionary properties to your Info.plist. Next, you will add your web service's domain to the NSExceptionDomains dictionary.

For example, if I want to bypass the App Transport Security behavior for a web service on the host www.yourwebservicehost.com then I would do the following:

  1. Open your app in Xcode.

  2. Find the Info.plist file in Project Navigator and "right-mouse" click on it and choose the Open As > Source Code menu option. The property list file will appear in the right pane.

  3. Put the following properties block inside of the main properties dictionary (under the first <dict>).


<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>www.example.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

If you need to provide exceptions for additional domains then you would add another dictionary property beneath NSExceptionDomains.

To find out more about the keys referenced above, read this already mentioned technote.

@helloB 2015-09-22 21:41:44

This worked in 2 of my apps, but it's not working on a 3rd one. Has anyone else encountered a situation of using the above fix and still getting the same error message? (and yes I updated the dictionary to use my API domain, not the one in the code)

@YannickSteph 2015-10-06 08:01:20

Best ! Apple confirms that this solution using

@Dustin Williams 2015-10-07 13:30:55

Best answer, working solution.

@jimmont 2015-12-10 20:10:42

This worked for a Cordova/Phonegap/Ionic app editing file ./platforms/ios/<project>/<project>-Info.plist with NSAllowsArbitraryLoads=false and many exception domains to services with varying TLS/HTTP/HTTPS combinations. Initially used NSAllowsArbitraryLoads=true then adjusted, troubleshooting the rules through trial and error to comply with guidelines and submit for approval. Note config.xml <access origin=.../> statements partially populate this file, but currently requires adjustment by direct editing or via XCode to get the details correct.

@jimmont 2015-12-10 20:19:47

Also <access origin="*"/> (in config.xml) sets NSAllowsArbitraryLoads=true (for Cordova/Phonegap/hybrid apps

@jww 2017-06-06 03:53:52

Why is NSExceptionAllowsInsecureHTTPLoads set to true? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@KMLong 2015-07-06 20:19:43

See the forum post Application Transport Security?.

Also the page Configuring App Transport Security Exceptions in iOS 9 and OSX 10.11.

For example, you can add a specific domain like:

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

The lazy option is:

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

Note:

info.plist is an XML file so you can place this code more or less anywhere inside the file.

@mursang 2015-07-11 13:34:02

not working for me with iOS9 beta 3. Any solution?

@user2443329 2015-07-24 20:46:35

Doesn't seem to be working in Beta 4 either.

@Dan Beaulieu 2015-07-26 03:29:15

worked for me in beta 4 build 7A121l

@lmiguelvargasf 2015-07-30 15:08:31

How can I do that, I mean what is the way to add this code to the Info.plist because I do not know where to paste this code?

@Dan Beaulieu 2015-07-30 20:24:24

@lmiguelvargasf open your info.plist in a plain text editor

@Dustt 2015-08-18 11:15:06

Works fine for me with beta 5. This should be the accepted answer.

@MB_iOSDeveloper 2015-08-27 09:12:56

The lazy options worked always. The domain option worked only if I added "www.mywebpage.com" in the .pliest file which I opened as source code. This solution worked for Xcode 7.0 beta 5 (7A176X) iOS 9.0 beta. self.thankYou("@KMLong") :)

@xBACP 2015-09-18 02:22:09

This added security in iOS 9 I forget about. This answers all helped me. Thanks...

@amit gupta 2015-09-22 10:20:48

by lazy options ,all web service working fine except one web service one web service return internal server error (500) in iOS 9 but working fine in iOS8 or later

@Supertecnoboff 2015-10-02 10:51:59

I love the lazy option ahahha :) The thing is though, what if you have lots of different website links which could potentially load.... you can't list them all.....

@hris.to 2015-10-06 08:28:42

Probably good to show official apple docs: developer.apple.com/library/prerelease/ios/technotes/…

@klaevv 2015-10-13 12:57:04

I still get the error: exception domain is set and NSAllowsArbitraryLoads is false. Even with NSAllowsArbitraryLoads set true the error shows up. Does anyone else here have this issue?

@Philippe Monnet 2016-01-30 21:32:17

As of 1/30/2016 Apple doc shows that the keys no longer have the Temporary word in them, e.g.: NSExceptionAllowsInsecureHTTPLoads NSExceptionMinimumTLSVersion See developer.apple.com/library/prerelease/ios/documentation/…

@BlueGuy 2016-02-24 07:26:38

In case anyone else is pulling their hair out because doing these simple changes to info.plist isn't working.. add the changes to Project>Target>Info>Custom iOS Target Properties

@GeneCode 2016-03-08 08:39:59

Im on XCode 7.2. Changed the keys without "Temporary" word in them. Still doesn't work. Anybody found a solution?

@Gurumoorthy Arumugam 2016-03-17 04:22:40

Its not working Xcode 7.2

@Felipe 2016-03-17 18:48:12

Thanks, mate! Worked fine on 9.2.1. Cheers.

@user1709076 2016-03-18 13:29:40

9.2.1 gives same error for me if i also add NSExceptionDomains after NSAllowsArbitraryLoads

@Tiago_nes 2018-07-06 10:13:48

Can´t use IOS simulator with this, only real devices

@Tiago_nes 2018-07-06 11:10:01

The best option for me was to make the api run in https

@Shailendra Suriyal 2017-01-09 06:28:32

Go to your Info.plist

  1. Right Click on empty space and Click on Add Row
  2. Write the Key Name as NSAppTransportSecurity, Under it
  3. Select Exception Domains, Add a new item to this
  4. Write down your domain name that needs to get accessed
  5. Change the Domain type from String to Dictionary, add a new Item
  6. NSTemporaryExceptionAllowsInsecureHTTPLoads, that will be a boolean with a true value. Look at the picture to follow it correctly

@jww 2017-06-06 04:05:46

Why is NSAllowsArbitraryLoads set to true? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@ObjectiveTC 2016-09-12 18:17:38

NOTE: The exception domain in your plist should be in LOWER-CASE.

Example: you have named your machine "MyAwesomeMacbook" under Settings->Sharing; your server (for test purposes) is running on MyAwesomeMacbook.local:3000, and your app needs to send a request to http://MyAwesomeMacbook.local:3000/files..., your plist you will need to specify "myawesomemacbook.local" as the exception domain.

--

Your info.plist would contain...

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>myawesomemacbook.local</key>
    <dict>
      <!--Include to allow subdomains-->
      <key>NSIncludesSubdomains</key>
      <true/>
      <!--Include to allow HTTP requests-->
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
    </dict>
  </dict>
</dict>

@Heedoo 2015-09-25 02:41:03

On 2015-09-25 (after Xcode updates on 2015-09-18):

I used a non-lazy method, but it didn't work. The followings are my tries.

First,

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>www.xxx.yyy.zzz</key>
        <dict>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

And second,

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>www.xxx.yyy.zzz</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

Finally, I used the lazy method:

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

It might be a little insecure, but I couldn't find other solutions.

@jww 2017-06-06 03:58:59

Why is NSAllowsArbitraryLoads set to true? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@Mark DeWald 2015-10-01 18:41:04

Like many have noted, this is a feature issue that comes with iOS 9.0. They have added a thing called App Transport Security, and I too was annoyed when it broke my Apps.

You can bandage it with the NSAllowsArbitraryLoads key to YES under NSAppTransportSecurity dictionary in your .plist file, but ultimately you will need to re-write the code that forms your URLs to form the HTTPS:// prefix.

Apple has re-written the NSUrlConnection class in iOS 9.0. You can read about it in NSURLConnection.

Else, you may have to back out of iOS 9.0 until you have time to implement the correct solution.

@Naishta 2015-10-25 17:18:29

It may be worth mentioning how to get there...

Info.plist is one of the files below the Main.storyboard or viewController.swift.

When you click on it the first time, it usually is in a table format, so right click the file and 'open as' Source code and then add the code below towards the end, i.e.:

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

Copy paste the code just above

 "</dict>
</plist>"

which is at the end.

@jww 2017-06-06 04:00:00

Why is NSAllowsArbitraryLoads set to true? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@MkaysWork 2015-10-27 19:21:57

Update for Xcode 7.1, facing problem 27.10.15:

The new value in the Info.plist is "App Transport Security Settings". From there, this dictionary should contain:

  • Allow Arbitrary Loads = YES
  • Exception Domains (insert here your http domain)

@Sebastian 2015-11-30 08:49:43

Development Example

Here is a screenshot of a plist which keeps ATS intact (=secure), but allows that connections to localhost can be made via HTTP instead of HTTPS. It works in Xcode 7.1.1.

Enter image description here

@milkersarac 2017-01-20 07:44:07

Are there any ways to make localhost secure, i.e. using HTTPS, in react-native so that we do not have to use the default NSExceptionAllowsInsecureHTTPLoads - YES config?

@Tejinder 2015-09-21 09:11:24

Use:

PList Screenshot to understand better

Add a new item, NSAppTransportSecurity, in the plist file with type Dictionary, then add sub item NSAllowsArbitraryLoads in dictionary of type Boolean, and set bool value YES. This works for me.

@Thiago Arreguy 2015-09-21 16:12:03

NSAllowsArbitraryLoads must be false, if true it allows all insecure connection

@amit gupta 2015-09-22 10:18:24

by adding in plist all web service working fine except one web service one web service return internal server error (500) in iOS 9 but working fine in iOS8 or later @ThiagoArreguy

@jww 2017-06-06 03:51:02

Very bad advice; see The most dangerous code in the world: validating SSL certificates in non-browser software. Given the question if full of the recommended way to do things, "me too" answers like this are not needed.

@Tejinder 2017-06-06 04:03:34

I Know its a bad advice, but it's just a solution for the time being in development mode only. Apple has provided us flexibility, if its that much bad, they wouldn't allow this.

@Malek Belkahla 2015-09-18 17:36:54

Transport security is available on iOS 9.0 or later. You may have this warning when trying to call a WS inside your application:

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

Adding the following to your Info.plist will disable ATS:

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

@Thiago Arreguy 2015-09-19 12:03:51

NSAllowsArbitraryLoads must be false, if true it allows all insecure connection

@amit gupta 2015-09-22 10:18:52

by adding in plist all web service working fine except one web service one web service return internal server error (500) in iOS 9 but working fine in iOS8 or later

@Vrashabh Irde 2015-09-23 09:15:51

Accepted on the store?

@jww 2017-06-06 03:49:53

Very bad advice; see The most dangerous code in the world: validating SSL certificates in non-browser software. Given the question if full of the recommended way to do things, "me too" answers like this are not needed.

@CristiCh 2015-08-04 10:42:04

Use:

Enter image description here

You have to set the NSAllowsArbitraryLoads key to YES under NSAppTransportSecurity dictionary in your .plist file.

Plist configuration

@Jacksonkr 2015-08-29 17:37:29

Let it be known: THIS IS A WORKAROUND! Anytime you're using HTTP over HTTPS you are opening up your user's device(s) to vulnerabilities. Sure it's unlikely in many cases but ethical programming is best practice. Just sayin' ... - also, +1 for the working (for testing purposes)

@Kurotsuki 2015-08-31 12:30:55

Thanks. Anyway ... Of course this is just a workaround. Production apps should always use https whenever possible. I only use this workaround for development phase.

@DiscDev 2015-09-16 17:25:56

This is NOT a solution - this is a HACK! To add individual domain "exceptions" see this answer below: stackoverflow.com/a/32560433/1103584

@Leo Flaherty 2015-10-01 11:10:23

This is a bad answer because it chooses the LEAST secure solution to the problem and offers it alone, with absolutely no context which might inform the questioner as to what implications need to be considered when choosing this option, or what problems they might encounter. Since there was already an answer that gave a more secure solution, but also included this solution with the necessary caveat, your answer was totally unnecessary and obsolete before ever being posted. This is a bad answer.

@reTs 2015-11-03 11:42:13

While this solution is known to be vulnerable, it is the only solution I would recommend during DEVELOPMENT. Having to type in every exact domain during development is just silly (especially if you are using third party web services).

@euccas 2015-11-21 21:16:25

Although this solution is known as a "workaround", sometimes it's the only solution. My app uses third party web services, and need redirect users to URLs of all kinds of different product webs which might use http instead of https. It's impossible to explicitly write down all domain names in the exception list.

@Leo Flaherty 2015-11-23 10:23:27

KMLong and whyceewhite have (and had at the time of this answer) both already given answers which include the information included here as well as a more secure solution which is better to use when possible, as well as an explanation of why the problem is happening in the first place and what needs to be considered when choosing how to address it. This answer on the other hand merely shoves some code that is easy to copy-paste without giving anyone any concept of what consequences it might have. Anyone who's serious about making a good product should care about understanding what they're doing

@vishal dharankar 2015-12-21 11:28:02

Name of those keys have changed now "App Transport Security Settings" under that "Allow Arbitrary Loads"

@ski_squaw 2016-01-15 19:43:08

I just updated my apps to IOS 9. This security improvement seems pretty half baked (like the original iCloud APIs). I ended up using this override, although I tried putting individual sites. They failed intermittently with app transport errors, so I gave up. Guess we have to wait until IOS 10

@user5273262 2016-03-24 12:58:30

@Jacksonkr: there are servers you can't control directly, you can't ask them to switch to https

@Jacksonkr 2016-03-24 13:19:42

@IanBell Technically you can ask them, but to your point they can always say no. My aim was to put caution out there, that is all.

@user5273262 2016-03-24 13:42:39

@Jacksonkr: very often lots of open data are not https

@Oren 2016-04-05 04:31:11

Why are so many people against this solution? This definitely is NOT a hack! Many apps need to communicate to the actual internet where the security protocol is not always under your control. For example, it seems very reasonable to be able to show images from other servers that don't have an SSL certificate.

@Paraneetharan Saravanaperumal 2016-06-15 10:10:05

It is never going to work after this year. stackoverflow.com/questions/31254725/…

@wottle 2016-08-02 18:25:29

@ParaSara That is not true. You will simply need to provide a justification to Apple. If you have a valid reason to disable ATS, they will allow it. Now, it remains to be seen what Apple sees as a "valid reason". Also, you can continue to disable the forward secrecy aspect of ATS with no need for justification.

@Sven Slootweg 2017-09-29 09:19:36

@Oren You can trivially set up an image proxy, if you need to do that. People are against disabling ATS because it is a significant security risk, and it's not something you should ever do.

@zeusstl 2016-03-21 12:41:01

For Cordova, if you want to add it into your ios.json, do the following:

"NSAppTransportSecurity": [
   {
      "xml": "<dict><key>NSAllowsArbitraryLoads</key><true /></dict>"
   }
]

And it should be inside of:

"*-Info.plist": {
   "parents": {
   }
}

@zeusstl 2016-03-21 12:45:45

Just <access origin="*" /> in config.xml didn't work. Not sure if both are necessary, but the ios.json solution sealed the deal for me.

@jww 2017-06-06 04:02:32

Why is NSAllowsArbitraryLoads set to true? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@Jayprakash Dubey 2016-03-10 11:29:32

Apple Document 1

Apple Document 2

There are two solutions for this :

Solutions 1 :

  1. In Info.plist file add a dictionary with key 'NSAppTransportSecurity'
  2. Add another element inside dictionary with key 'Allow Arbitrary Loads'

Plist structure should appear as shown in below image.

Solution 1

Solution 2 :

  1. In Info.plist file add a dictionary with key 'NSAppTransportSecurity'
  2. Add another element inside dictionary with key 'NSExceptionDomains'
  3. Add element with key 'MyDomainName.com' of type NSDictionary
  4. Add element with key 'NSIncludesSubdomains' of type Boolean and value set as YES
  5. Add element with key 'NSTemporaryExceptionAllowsInsecureHTTPLoads' of type Boolean and value set as YES

Plist structure should appear as shown in below image.

Solution 2

Solution 2 is preferred since it allows only selected domain whereas solution 1 allows all insecure HTTP connections.

@jww 2017-06-06 04:02:08

Why is NSAllowsArbitraryLoads set to YES? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@Vincent 2015-11-06 08:06:57

I do not like editing the plist directly. You can easily add it to the plist using the GUI:

  • Click on the Info.plist in the Navigator on the left.
  • Now change the data in the main area:

    • On the last line add the +
    • Enter the name of the group: App Transport Security Settings
    • Right click on the group and select Add Row
    • Enter Allow Arbitrary Loads
    • Set the value on the right to YES

Example

@user3821934 2015-11-20 00:40:34

To clarify: if "Allow Arbitrary Loads" is YES, and there are "Exception Domains", then the loads that are allowed are restricted to the ones in the Exception Domains. Is that correct?

@Lamar 2016-02-19 11:13:15

is that a safe way to do it if I want to release the application?

@Raptor 2017-01-05 02:33:22

No. By allowing arbitrary loads, your app can connect to any domains freely. In security point of view, you should control & limit which domain / website should the app connect to, to avoid unexpected network usage.

@Vincent 2017-01-05 10:26:53

Most apps route only to known servers. This is controlled by the developer. So the security Issues are known.

@jww 2017-06-06 04:00:48

Why is NSAllowsArbitraryLoads set to YES? You subvert the purpose of ATS. Also see The most dangerous code in the world: validating SSL certificates in non-browser software. Your software just made the list.

@Vincent 2017-06-06 07:48:33

Sometimes you have to access a non-secure website. In those cases you can use the code above. In all other cases using SSL is advised.

@user2659694 2018-12-10 10:09:18

It not work in my project :(

@Vincent 2018-12-10 16:52:24

I have implemented this is multiple projects. All work. Can you give more info on your case?

@William Cerniuk 2015-11-14 19:08:03

Here are the settings visually:

visual settings for NSAllowsArbitraryLoads in info.plist via Xcode GUI

@Paul 2015-11-20 18:40:01

I am using PhoneGap and this worked perfectly. Exactly the trick to avoid the issue. Now I can build. Thank you!

@user5273262 2016-03-03 10:57:40

This worked for me, while plist editing didn't

@User 2016-03-29 03:26:38

I don't have that option.

@Stoph 2016-04-01 15:40:03

If you open your Info.plist directly you can just add the NSAppTransportSecurity dictionary, and then create the NSAllowsArbitraryLoads item within that (see the answer edited by Umar Farooq, below).

@JavaLatte 2016-04-02 19:43:14

The silver bullet worked for me, but the Exception domains did not.

@RegularExpression 2016-04-10 05:15:00

Same here -- exception domains didn't work with 7.3 for me.

@Umitk 2016-04-21 03:56:16

i was busy configuring info.plist which didnt work until i see this! thanks ;)

@Epaga 2016-04-25 17:48:47

exception domains weren't working for me, either, but i figured out why - the domain I was trying to contact (in my case, covers.openlibrary.org) was only redirecting to a different domain (in my case, ol-covers1.us.archive.org) - when I added that 2nd domain as an exception domain, it worked.

@nickalchemist 2016-05-06 07:36:22

not working for iOS 9.3. any tips?

@nafsaka 2016-06-01 07:31:41

@nickalchemist: It's working on iOs 9.3.1. Just met with the same problem.

@samouray 2016-06-08 08:58:59

i am using xcode 7, and while i was testing my app on an ipad I encounterd this problem, this particular solution helped me and fixed it.

@Paraneetharan Saravanaperumal 2016-06-15 10:09:00

It is never going to work after this year. stackoverflow.com/a/37830469/4947520

@jameshfisher 2016-06-23 13:14:48

This option does not exist - XCode 7.3.1

@William Cerniuk 2016-09-03 12:20:22

Just confirmed it works the same way in Xcode 8b6.

@Jakub Truhlář 2017-01-03 15:57:16

NOTE: Soon this won't be possible since Apple will require ATS (Originally the end of the year - deadline has been extended) - developer.apple.com/news/?id=12212016b

@Edmund 2017-01-17 20:40:17

Right click App Transport Security Settings, not Bundle OS Type Code

@Joshua Pinter 2017-02-11 08:51:00

When you add an domain to the Exception Domains, you need to make it look like this: dropbox.com/s/3q32sx1h5t6hu20/…

@Joshua Pinter 2017-02-11 19:56:27

Also, I read somewhere that the docs say the domain must be a string, not an IP Address.

@Matthew Bellantoni 2017-03-21 19:32:05

The info from @JoshPinter worked for me with XCode 8.

@BHUVANESH MOHANKUMAR 2017-03-23 14:10:35

This works in Xcode Version 8.2.1 (8C1002), March 2017 - Thanks.

@MagnunStalin 2017-07-27 01:34:28

Thanks it works.

@Daniel Molina 2017-09-08 11:11:16

This worked for me, while plist editing didn't (2)

@Alex Zavatone 2019-03-10 20:53:47

FYI, this IS the contents of your info.plist

@ecotax 2015-10-07 08:29:36

Figuring out what settings to use can be performed automatically, as mentioned in this technote:

/usr/bin/nscurl --ats-diagnostics --verbose https://your-domain.com

@ecotax 2015-10-07 08:43:23

You do need OS X 10.11 (El Capitan) for this, apparently.

Related Questions

Sponsored Content

13 Answered Questions

[SOLVED] How can I add NSAppTransportSecurity to my info.plist file?

2 Answered Questions

1 Answered Questions

[SOLVED] Transport security has blocked a cleartext HTTP (XCode 8)

1 Answered Questions

1 Answered Questions

2 Answered Questions

1 Answered Questions

[SOLVED] Cleartext HTTP blocked

Sponsored Content