SSL and ios app

My ionic app requests data from an API that is accessed via https (SSL certificate, TLS 1.2). Whenever I test my app (ionic emulate ios [ios emulator] or ionic run ios [on iPhone used for development connected via USB]), I cannot access the API and get the following error when I debug using Safari.

“Failed to load resource: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “” which could put your confidential information at risk.”

The SSL certificate appears to be working correctly when I access the website in a browser and when I emulate android (ionic run android with genymotion).

Does anyone know a potential solution to this problem? Could it potentially be a CORS type issue?

I did find this article:, but it would require editing in Objective C (in Xcode). I would prefer if there was an “angular” or “ionic” solution if possible.

I believe I’m having a similar issue. I get the following showing up in the iOS emulator logs:

: NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)

I was able to solve the problem. The problem had to do with the way I had my ssl certificate set up on the server. On nginx, the ssl certificate and intermediate certificates need to follow each other in the same file. I used to find errors in my certificates. Now that the problem has been fixed with the certificate on the server, I don’t get the errors anymore.

I did find the following packages that may be useful if it’s not a problem with the certificate:

cordova-HTTP is exactly what I’m looking for. I have it building cleanly but am unable to access it while I can access other plugins fine. Can anyone with more advanced skills shed some light on this plugin? It seems pretty well documented, and being able to use the device’s network seems like it may come in handy for a variety of reasons, accepting self signed certs being but one. I’d change the cert but it’s in a 3rd party pre-compiled product that I have zero control over.


Any luck with this issue?

I still have problem with this error. Can anyone offer detail solution how to fix this?

1 Like

fixed. turned out to be problem with nginx configuration.

1 Like

This response was totally unhelpful, but it pointed me in the right direction.

The problem turned out to be that I hadn’t properly included the certificate chain provided by my CA (GoDaddy) in the cert file. The directions for this are here:

In my case, this meant appending the gd_bundle-g2-g1.crt chain provided by GoDaddy to the server cert, then pointing nginx’s ssl_certificate path to the chained crt file. I had installed only the 0123456789abcdef.crt file in the downloaded bundle, which worked fine for those browsers that had trusted the GoDaddy certificate but not for Ionic or some other browsers.