Created
January 4, 2015 15:53
-
-
Save hardez/985ce910f82f151b01e2 to your computer and use it in GitHub Desktop.
NSURLConnectionDelegate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func connection(connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: NSURLProtectionSpace?) -> Bool | |
{ | |
return protectionSpace?.authenticationMethod == NSURLAuthenticationMethodServerTrust | |
} | |
func connection(connection: NSURLConnection, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge?) | |
{ | |
if challenge?.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust | |
{ | |
if challenge?.protectionSpace.host == "www.myhost.com" | |
{ | |
let credentials = NSURLCredential(forTrust: challenge!.protectionSpace.serverTrust) | |
challenge!.sender.useCredential(credentials, forAuthenticationChallenge: challenge) | |
} | |
} | |
challenge?.sender.continueWithoutCredentialForAuthenticationChallenge(challenge) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment