Load HTTPS url in a UIWebView
14,080
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];
}
Author by
Borneto
Updated on July 02, 2022Comments
-
Borneto almost 2 years
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 aboutASIHTTPRequest
but I didnt arrive to implement it.I just want to load HTTPS URL.
-
Nurbol over 11 yearsDo I just add this to the UIViewController containing the UIWebView? I'm not quite sure what to do with this.
-
Admin over 11 yearsThese two methods are part of the NSURLConnectionDelegate protocol, so you put them in whichever file is acting as the delegate for your NSURLConnection.
-
m4n1c about 11 yearsi was also using a self assigned certificate and it worked with the above implementation.