Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send HTTPS requests to host with untrusted server certificate in iPhone Simulator?

I develop an iPhone framework which sends HTTPS requests in order to communicate with a publicly available backend server. Currently I have a big problem regarding untrusted server certificates.

The certificate of the backend server is not signed by a trusted CA, so my first approach was to use NSURLRequest's private allowsAnyHTTPSCertificateForHost. While this worked as expected and was fine as temporary workaround, our customer demands a clean solution as final result. Therefore I wrote a method which allows to install a provided certificate from the file system in the keychain, but this method does not work as expected in the iPhone Simulator. The certificate is installed in the host machine's Mac OS X keychain instead. Unfortunately, if I call NSURLConnection's sendSynchronousRequest method, I retrieve an "untrusted server certificate" error. It seems as if NSURLConnection is not able to access the host's Mac OS X keychain to retrieve the certificate.

Is my guess correct or did I miss something?

Would my approach work if I ran my app on a real iPhone device instead (I do not have one available yet)?

Does there exist a keychain in the iPhone Simulator at all?

Is it at all possible to send HTTPS requests to a server with an untrusted certificate on the iPhone Simulator or do I have to use precompiler directives to implement different routines depending on the underlying platform (simulator or device, respectively)?

Any help is highly appreciated.

Thanks, Matthias

like image 205
ma77h1a5 Avatar asked Jan 12 '10 16:01

ma77h1a5


People also ask

How do I fix not trusted server certificate on iPhone?

If you want to turn on SSL/TLS trust for that certificate, go to Settings > General > About > Certificate Trust Settings. Under "Enable full trust for root certificates," turn on trust for the certificate.

What is certificate trust settings iPhone?

An iPhone and iPad can update certificates wirelessly if any of the preinstalled root certificates become compromised. You can disable this feature using the mobile device management (MDM) restriction, “Allow automatic updates to certificate trust settings,” which prevents wireless certificate updates.


1 Answers

You can get free trusted SSL certificates at http://startssl.com

like image 89
Beat Bolli Avatar answered Oct 30 '22 21:10

Beat Bolli