views:

41

answers:

1

I am requesting some data from a server with NSString#stringWithContentsOfURL:. The server is using a self-signed certificate, so stringWithContentsOfURL: simply returns nil and does not give a change to accept the certificate.

This is all expected behaviour. I know how to properly do this with NSURLConnection and it's delegate methods instead, but I am looking for a shorter term fix instead of rewriting this code. (Yay deadlines)

So my question is, is it possible to import the self-signed certificate into the application's keychain, and will that cause stringWithContentsOfURL: to accept the self-signed certificate?

A: 

I beleive that there is an enterprise tool from Apple for installing SSL certs -- it was necessary to get exchange mail working.

You may also be able to mail the .cer file to yourself, open on your iPhone and install it.

There is also the AdvancedURLConnections sample project from Apple

This sample demonstrates various advanced networking techniques with NSURLConnection. Specifically, it demonstrates how to respond to authentication challenges, how to modify the default server trust evaluation (for example, to support a server with a self-signed certificate), and how to provide client identities.

TomH