iPhone Simulator custom CA certificate

2019-06-23 08:20发布

问题:

I'd like to test an application on the iphone simulator which connects to a service using a certificate which is signed by our own CA. I can do this on the actual device by adding a provisioning profile which has the CA certificate. I had thought that having the CA certificate in the standard OSX keychain would work, but it doesn't.

So I can access the service via Safari without warning, but I get error when trying to run things in simulator.

回答1:

The crypto api's are unavailable to the simulator. I think someone at apple was smoking crack when they made this decision because i fail to see how having an iPhone changes the out come of a cryptographic algorithm. Never the less in order to develop with these systems you'll need an iphone or ipod touch.



回答2:

This link worked for me

canAuthenticateAgainstProtectionSpace method set to return yes. NOTE: this will accept any certificate so should be removed for production releases: ie: ONLY for testing



回答3:

It seems to work okay when I point the emulator at one of our live servers which a use a 'real' certificate. But I've just been getting 1200 errors trying to get the emulator to talk to a local test server I set up this morning.

So there must be crypto libraries there (or our app wouldn't talk to the live servers with real certificates), but there certainly seems to be a problem with self-signed certs.