NSExceptionAllowsInsecureHTTPLoads not working for IP addresses

excluding ATS on iOS 9 does not work for me.

I have a test server that does not have a domain name (only an IP address) and does not have an SSL certificate (this is HTTP, not HTTPS)

I tried:

<key>52.24.145.252</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> </dict> 

But I still get the error:

 App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app Info.plist file. 

What am I doing wrong?

+1
source share
3 answers

You need to add the NSAppTransportSecurity dictionary to your info.plist . Then add NSAllowsArbitraryLoads to this dictionary and set boolean to YES .

Disabling ATS

Update

Since 2017, if you use the above method to opt out of ATS, you need to provide Apple justification when submitting the app to the AppStore.

Vehicle Safety Applications REQUIRED January 2017

+6
source

Try the following:

enter image description here

Or, as the source code:

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

How it works (if your domain is correct) in iOS 9.1.

+4
source

In fact, the real problem is that in iOS 9, ATS exceptions do not work with IP addresses. It only works with domain names. Disabling ATS in general is a bad idea, and you will justify this decision if you want to send it to the application store after 12/31/2016.

Unfortunately, there is no good solution for this, so as not to get the domain name for the server you are trying to connect to.

Others have successfully used the xip.io service to "translate" a local IP address into a domain name. So you added xip.io to the exception clouds, set the value under NSIncludesSubdomains to true. Then, when you connect to your domain, instead of connecting to 52.24.145.252 you should connect to 52.24.145.252.xip.io

+1
source

Source: https://habr.com/ru/post/1233328/


All Articles