Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1820

How do I accept a self-signed SSL certificate using iOS 7's NSURLSession

$
0
0

I have the following code (swift implementation):

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 == "myDomain"        {            let credentials = NSURLCredential(forTrust: challenge.protectionSpace.serverTrust)            challenge.sender.useCredential(credentials, forAuthenticationChallenge: challenge)        }    }    challenge.sender.continueWithoutCredentialForAuthenticationChallenge(challenge)}

It works perfectly in iOS 8.x, but does not work iOS 7.xIn iOS 7.x I have error:

NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)

Any idea?thank you!!!


Viewing all articles
Browse latest Browse all 1820

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>