13

enter image description here

I am using Socket.IO library in swift and I keep 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.

when I am trying to send an http request. I added the keys to plist according to the official apple documentation, but it did not help.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Narek Simonyan
  • 572
  • 1
  • 7
  • 18
  • possible duplicate of [Transport Security has Blocked a cleartext HTTP](http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http) – brainray Sep 29 '15 at 14:52
  • @william-kinaan Please do not add irrelevant tags to questions. This question is not related to Swift but to iOS. Thank you. – Eric Aya Apr 18 '16 at 09:02

6 Answers6

30

You need to correct it like this:

enter image description here

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.

William Kinaan
  • 28,059
  • 20
  • 85
  • 118
  • 1
    I did the exact same thing and I am getting this now: 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. Please help.. – Mohsin Khubaib Ahmed Dec 29 '15 at 13:43
  • I'm completely new to XCode. I have 7.3 so I see the same variable names **except** that they don't have *NS* in the names. So this solution worked for me! – ebichuhamster Apr 16 '16 at 20:20
6

Another way to solve this, which I found more convenient, is to disable App Transport Security by default using the NSAllowsArbitraryLoads key. So any domains you do not include in the NSExceptionDomains dictionary (or if you don't include NSExceptionDomains at all) will not be subject to App Transport Security.

enter image description here

strwils
  • 687
  • 4
  • 12
4

I see a wrong key and a typo in your screenshot. Here is a working example:

screen

rshev
  • 4,086
  • 1
  • 23
  • 32
  • Thanks for this fix! I couldn't download Facebook profile info from the graph.facebook.com domain until I added that NSExceptionAllowsInsecureHTTPLoads exception. Works as expected now. Cheers! – Mike Critchley Jan 28 '16 at 10:37
3

Xcode project -> go to info.plist and Click + Button then Add (App Transport Security Settings)Expand, Allow Arbitrary Loads Set YES. Thanks

Shanmugasundharam
  • 2,082
  • 23
  • 32
1

I'm working in xCode 8.2. It's a little different, but editing the PLIST file you need to add this two Items in the App Transport Security Settings Line... :

Allow Arbitrary Loads and Allow Arbitrary Loads in Web Content... and give them both the key YES.

It worked for me, hope this work for you and sorry for my English.

enter image description here

enter image description here

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
0

@William Kinaan has the best answer, but it would seem to make best sense to be sure to add the NSAllowsArbitraryLoads underneath the exception domain "localhost" ... and not at the higher NSTransportSecurity level which opens that up to all domains.

J.Doe
  • 17
  • 6