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];
}
Share:
14,080
Borneto
Author by

Borneto

Updated on July 02, 2022

Comments

  • Borneto
    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 about ASIHTTPRequest but I didnt arrive to implement it.

    I just want to load HTTPS URL.

  • Nurbol
    Nurbol over 11 years
    Do I just add this to the UIViewController containing the UIWebView? I'm not quite sure what to do with this.
  • Admin
    Admin over 11 years
    These two methods are part of the NSURLConnectionDelegate protocol, so you put them in whichever file is acting as the delegate for your NSURLConnection.
  • m4n1c
    m4n1c about 11 years
    i was also using a self assigned certificate and it worked with the above implementation.