Michaël
Michaël

Reputation: 6734

How to check ssl certificate of https request on iPhone

I am making an iPhone app with the aim of connecting to a wifi hotspot.
The connection to the hotspot is made with a https web page.

In order to identify if the web page is a real hotspot, not a fake hotspot to steal logins, I want to check the https certificate of the web page. The web page is loaded in a UIWebview.

Questions : How I can retreive informations about the https certificate ?

EDIT : I think that should be possible with the NSURLConnection but with a UIWebView, I haven't the NSURLConnection object.

Thanks for your answers !

Upvotes: 1

Views: 4235

Answers (1)

lxt
lxt

Reputation: 31304

You can't do this with a UIWebView, but you can using the canAuthenticateAgainstProtectionSpace: delegate method for NSURLConnection. You can use this delegate method to create an NSData copy of the certificate you want to verify, and then compare it against a locally stored copy.

That said, as indicated above it doesn't really add much security, and there are better ways of achieving what you want to achieve.

Upvotes: 2

Related Questions