Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dataWithContentsOfURL iOS HTTPS self-signed certificate

I'm trying to download a JSON object from a page hosted on a web server, using the method

[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://<url>"]]

but it doesn't work. The same call with the same address with http:// instead of https:// works. The server has a self-signed certificate, and it's not trusted by iOS (by default).

What can I do to make it trustable by my app?

like image 767
boskaiolo Avatar asked Oct 22 '22 21:10

boskaiolo


1 Answers

Don't use +dataWithContentsOfURL: for this. Use NSURLConnection directly, which gives you delegate methods to properly control authentication.

like image 114
Mike Abdullah Avatar answered Oct 24 '22 16:10

Mike Abdullah