App Transport Security - Error Domain=NSURLErrorDomain Code=-1200

Axemasta picture Axemasta · Nov 17, 2017 · Viewed 8k times · Source

I have come across this 1200 error whilst building a POC and I'm really stuck as to what the actual problem is. Before you read this, I'm not looking for work arounds as I have already implemented a work around, I want to properly fix this issue.

In my app I am making a @POST HTTP request, the code for the request is fine and I make my request, get some json, parse and do whatever with it.

When building the app I was using CharlesProxy as a middleman so I could see the request I was sending out (as my password field wasn't getting encoded properly). After I built the POC I closes Charles and then the app stopped working.

I got these error logs in my console:

error : Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made."

I googled around for a fix and people seemed to suggest disabing transport security to prevent apple from interfering. The thing is the server I am interacting with is a HTTPS server and transport security is not picking up on this.

I've read that this is due to an error with the SSL handshake but nobody actually suggested any fixes.

For now I've changed the app transport security settings in my info.plist to allow arbitrary loads. Obviously I don't want to be doing this in my main app, I would like to know of a way to fix this once and for all! (and I can also run charles proxy alongside the app to get everything to work).

Answer

Kevin Pham picture Kevin Pham · Feb 18, 2020

I have encountered the same issue like you so I tried to add some code XML like this

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
    <dict>
    <key>codedeman.github.io</key>

codedeman.github.io it's subdomain of your url

It's work for me, i hope it useful for you