ho il seguente codice (rapida attuazione):Come faccio ad accettare un certificato SSL self-signed con iOS 7 del NSURLSession
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)
}
Funziona perfettamente in iOS 8.x, ma non funziona iOS 7 .x In iOS 7.x ho errore:
NSURLConnection/CFURLConnection HTTP carico non riuscita (kCFStreamErrorDomainSSL, -9813)
Qualche idea? grazie !!!
edwardmp grazie, funziona perfettamente: D –
È questo affatto sicuro senza pinning chiave pubblica? Per quanto posso vedere, non verificate che il certificato corrisponda a ciò che dovrebbe –
Come potete verificare le corrispondenze del certificato quando non utilizzate la chiave pubblica? Non è richiesto il blocco della chiave, ma lo consiglio perché ho incluso il link in fondo a uno snippet. – edwardmp