Connect to untrusted SSL servers on iPhone

by alex 29. September 2010 02:30

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *) space {

if([[space authenticationMethod] isEqualToString:NSURLAuthenticationMethodServerTrust]) {

// Note: this is presently only called once per server (or URL?) until

//       you restart the app

if(shouldAllowSelfSignedCert) {

return YES; // Self-signed cert will be accepted

} else {

return NO// Self-signed cert will be rejected

}

}

return NO;

}

 

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {

return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen