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

Viewed 2936

My app fetches resources from AWS bucket (accessed thru a cloudfront). Some of the users fails to fetch the data due to

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

As we use AWS service I assume that the SSL certificate is fine, the fact that it happens to a small (but not small enough) portion of the users should say that the SSL certificate is OK.

Any other post I saw about this issue suggested to add a flag to App Transport Security Settings in info.plist file that will allow unsecured connection. This is not something I can (or want) to do.

Thanks for the help :)

2 Answers
  • This might happen if you're using a VPN.
  • But will also happen if you're using a proxy tool like Charles Proxy but haven't installed/trusted the Charles Proxy certificate.
  • It also happened to me when I was on a public wifi network. It seemed that some how the public wifi was doing some sort of a MITM to maybe add some ads. I didn't face the same problem when I was using LTE or a non-public wifi

I found this solution from the Apple Developer Forums which does not involve modifying the App Transport Security Settings:

And you shouldn’t need an ATS exception in your scenario. The approach I recommend is as follows:

  • Set up a custom certificate authority (CA) within your organisation (many organisations already have this).

  • Have it issue a certificate for your private server.

  • Use MDM to install your organisation CA’s root certificate on your devices.

Related