Adding a self-signed certificate to iphone Simulator?

Viewed 57880

I have a self-signed certificate at the endpoint of my API. I'm trying to test some things using the simulator but am getting "untrusted server certificate".

I have tried to use safari on the simulator to download the .crt file, but that doesn't seem to work.

Where does iPhone Simulator get its keychain from? How can I add a trusted certificate so my application will work?

UPDATE

I got it to work by creating a CA and then adding a CA certificate using the iPhone provisioning tool. Then I was able to have a certificate signed by that CA certificate on the API server and the NSConnection just worked. I was not able to get it to work using a self-signed certificate for some reason. I need to re-attempt this using the provisioning software.

My real question is how do I get this to work on the simulator? I would think that the simulator uses the keychain of the actual computer.

9 Answers

Just for Info, if someone still runs into that problem:

simply drag & drop your .cer Files into your running Simulator window. You'll see Safari flashing and then the import dialog for your Certificate (or Certificate Authority)...

Working for iOS 7 Simulator (and i Think did work for iOS 6 too).

For anyone use OS X Catalina, please check this : https://forums.developer.apple.com/thread/124056.

Catalina is currently blocking access to Desktop, Documents and Downloads folder. I moved certificate files to Shared folder and drag and drop the files to simulator from there.

Dragging and drop used to work but it didn't work on XCode 12 for me. What worked for me was opening Safari browser on Simulator and then typing the file URL for the .crt certificate file. Ex.

file:///Users/[folder_path]/[certificate.crt]

After that you have to goto Simulator Settings and install the certificate by navigating into General > Profiles section.

Related