Question

I have to implement NSURLConnection with https if the certificate is trusted then connection should go normally if it is untrusted certificate then I have to get the confirmation from the user. How can I implement?

My Code..

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge 
{
    self.mHTTPLAuthenticationChallenge = challenge;
    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
    {


        NSString *theErrorMSG = [[NSString alloc]initWithFormat:@"The certificate for this server is invalid. You might be connecting to a server that is pretending to be \“%@\” which could put your confidential information at risk.",challenge.protectionSpace.host];

        UIAlertView *theAlertView = [[UIAlertView alloc]initWithTitle:kAppName message:[ARCUtilities ARCLocalizedString:theErrorMSG] delegate:self cancelButtonTitle:[ARCUtilities ARCLocalizedString:@"Continue"] otherButtonTitles:[ARCUtilities ARCLocalizedString:@"Cancel"], nil];
        [theErrorMSG release];

        [theAlertView show];
        [theAlertView release];
         [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];

    }

}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top