Skip to content

Instantly share code, notes, and snippets.

@mrmans0n
Created October 23, 2012 09:01
Show Gist options
  • Select an option

  • Save mrmans0n/3937747 to your computer and use it in GitHub Desktop.

Select an option

Save mrmans0n/3937747 to your computer and use it in GitHub Desktop.
Accept all SSL certificates
- (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 ([trustedHosts containsObject:challenge.protectionSpace.host])
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment