Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have explained below how to access https url in UIWebview it will help you clear the problem because it works for me. </p> <p>Calling http is same as https url.</p> <p>If, however, you're using a <em>self-signed certificate</em>, it's necessary to add some additional code.Because by default iOS will reject all untrusted https connections.</p> <p>Restricting untrusted connections is very good default behaviour and any disabling of this is highly risky.So we will show an alert as we're going to bypass the default behaviour. </p> <pre><code>-(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace; -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge; </code></pre> <p>These two above methods allows us to provide our own authentication mechanism for trusted connections</p> <pre><code>#import "ClassCon.h" // For now, I've hard coded the IP address of my trusted server. #define TRUSTED_HOST @"192.168.1.2" @implementation ClassCon { NSMutableData *contentData; NSURLConnection *conn; } -(void) loadContent { contentData = [NSMutableData data]; NSString *contentURL = @"our url"; conn = [[NSURLConnection alloc] initWithRequest: [NSURLRequest requestWithURL:[NSURL URLWithString:contentURL]] delegate:self]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [contentData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"Bad: %@", [error description]); ContentResponse *response = [[ContentResponse alloc]initWithRc:-999 andDescr:@"error" andAction:0]; conn = nil; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *loadedContent = [[NSString alloc] initWithData: contentData encoding:NSUTF8StringEncoding]; NSLog(@"Loaded content: %@",loadedContent); } // ------------ ByPass ssl starts ---------- -(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace: (NSURLProtectionSpace *)protectionSpace { return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; } -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { if (([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])) { if ([challenge.protectionSpace.host isEqualToString:TRUSTED_HOST]) { NSLog(@"Allowing bypass..."); NSURLCredential *credential = [NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust]; [challenge.sender useCredential:credential forAuthenticationChallenge:challenge]; } } [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; } // -------------------ByPass ssl ends @end </code></pre> <p>Hope this helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload