I have to connect my iPhone app to a server with a self-signed certificate via HTTPS. I cannot change the certificate or the server.
Since I don't want to accept all self-signed certs, just this one, my idea was to import the cert to the apps keychain (reading the cert from file and adding it to the keychain with SecItemAdd
).
If I run the App in the Simulator, install the cert and then search the keychain for it (using SecItemCopyMatching
), the cert is found, but the connection still fails with "untrusted server certificate" error.
Is this a problem with the simulator or my app? Do I have to do anything else, for this to work? Or can I assume, that if I add a certificate to the keychain on a real device, the connect to the server will be successfull(I'm using NSURLConnection.sendSynchronousRequest
)?
Thanks for any help!