We have an iOS app that uses a UIWebView to display content. We load it up with data with code that looks like this:
NSURL *url = [NSURL URLWithString:myURLString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView setDelegate:self];
[_webView loadRequest:request];
This used to work fine with HTTP requests, but now we are using HTTPS against a server with a self-signed SSL certificate. When the above is run, the webView:didFailLoadWithError:
delegate method gets called, with this error:
The certificate for this server is invalid. You might be connecting to a server that is pretending to be "blah.blah.blah.com" which could put your confidential information at risk."
I would like to simply ignore the invalid certificate and go on with the request, as one can do in Mobile Safari.
I have seen how to work around this issue when using NSURLConnection
(see HTTPS request on old iphone 3g, for example), but what can one do with a UIWebView
?
I imagine that I could rework the code so that it uses NSURLConnection
to make the requests and then puts the results into the web view by calling its loadHTMLString:baseURL:
method, but that's going to get complicated when the pages have images, CSS, JavaScript, and so on. Is there an easier way?