NSTemporaryExceptionAllowsInsecureHTTPLoads not working

Hi,


From my app, I am trying to load a HTTP site (http://m.tata-daewoo.com/) in a webview. I have configured my app’s info.plist file and added this site to ExceptionDomains in ATS with NSTemporaryExceptionAllowsInsecureHTTPLoads set to true.


<key>NSAppTransportSecurity</key>

<dict>

<key>NSExceptionDomains</key>

<dict>

<key>m.tata-daewoo.com</key>

<dict>

<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>

<true/>

</dict>

</dict>

</dict>


Still I'm unable to open this HTTP site from my app. I also treid using NSAllowsArbitraryLoadsInWebContent set to true, while removing ExceptionDomains. But that didn't work too.


I also tried running this command in terminal.

nscurl --ats-diagnostics --verbose http://m.tata-daewoo.com


But the Result is FAIL in all cases.


Any idea what can be done to get this working?



Thanks & Regards,

Suman

NSExceptionAllowsInsecureHTTPLoads
is working for me. Here’s what I did specifically:
  1. Starting with Xcode 11.3, I created a new iOS test project.

  2. I added this code to the project:

    NSLog("task will start") let url = URL(string: "http://m.tata-daewoo.com/")! let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 60.0) URLSession.shared.dataTask(with: request) { (data, response, error) in     if let error = error as NSError? {         NSLog("task transport error %@ / %d", error.domain, error.code)         return     }     let response = response as! HTTPURLResponse     let data = data!     NSLog("task finished with status %d, bytes %d", response.statusCode, data.count) }.resume()

    .

  3. On the iOS 13.3 simulator [1], this is blocked by ATS.

  4. I added the following ATS dictionary to the app.

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>m.tata-daewoo.com</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

    .

  5. Retesting, it works just fine:

    2020-01-31 08:42:09.234545+0000 xxsi[39472:704817] task will start
    2020-01-31 08:42:10.245609+0000 xxsi[39472:705001] task finished with status 200, bytes 3988

    .

Please repeat my test to confirm that it’s working in your environment. If so, you should look at the differences between your test and mine to see if you can work out why your test is failing.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] My experience is that the simulator is very accurate when it comes to ATS issues.

Hi,


Thanks for your reply.


The code in step 2, where should I add it in my project?


Also FYI I'm using iOS simulator v11.2.1.

The code in step 2, where should I add it in my project?

Ah, um, you don’t need to add my code to your project; I presume you already have code that talks to your server. I posted my code to show how I tested it.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
NSTemporaryExceptionAllowsInsecureHTTPLoads not working
 
 
Q