2

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

Axemasta
  • 763
  • 1
  • 9
  • 24
  • Possible duplicate of [iOS9 getting error “an ssl error has occurred and a secure connection to the server cannot be made”](https://stackoverflow.com/questions/32755674/ios9-getting-error-an-ssl-error-has-occurred-and-a-secure-connection-to-the-ser) – Tushar Sharma Nov 17 '17 at 17:18
  • ATS is very strict, and it requires servers to match quite a few requirements, which go way being just "SSL": TLS versions, cipher suite, key... See https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW57 for details. – jcaron Nov 17 '17 at 17:22
  • See also https://stackoverflow.com/questions/34444472/best-way-for-verifying-server-compliance-to-apples-ats-tls-1-2-requirement and https://apptransport.info – jcaron Nov 17 '17 at 17:27
  • 1
    @TusharSharma So the problem is, the server I'm connecting to is HTTPS and I don't want to disable transport security as it will introduce a security flaw in my app. I was looking for a proper solution to handling this error :/ – Axemasta Nov 19 '17 at 01:41
  • @jcaron Thanks a lot our servers TLS version was the issue. Going to get it upgraded and hopefully everything works! – Axemasta Nov 20 '17 at 11:41
  • 4
    On a mac, run `nscurl --ats-diagnostics ` with your URL and it should point you to what is not ATS compliant about the URL. – wottle Nov 25 '17 at 05:57
  • @wottle I visited apptransportinfo and found my server is running an older version of tls. – Axemasta Nov 26 '17 at 16:12
  • Also see https://stackoverflow.com/a/62696440/5175709 – mfaani Jul 02 '20 at 12:39

1 Answers1

0

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

Kevin Pham
  • 19
  • 5