Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load HTTPS url in a UIWebView

I begin iPhone programming and I have big problem I cant resolve.

So, I have a UIWebview, I can load HTTP url without problems :

NSString urlAdress;
urlAdress = @"http://servername";
NSURL *url = [NSURL URLWithString:urlAdress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];

Its work, my page is load in my UIwebView, but when I replace :

urlAdress = @"http://servername";

by

urlAdress = @"https://servername";

I have blank screen.

I read its normal, but is there easy method to load https url in my webview ?
I read about ASIHTTPRequest but I didnt arrive to implement it.

I just want to load HTTPS URL.

like image 773
Borneto Avatar asked Jun 10 '11 14:06

Borneto


1 Answers

Try this :

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
    return YES;
}


- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}
like image 141
Niko Avatar answered Oct 02 '22 02:10

Niko