Nsurlsession "Http Load Failed Kcfstreamerrordomainssl, -9813 ; Self Signing Certificate

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) error in https connection

As per the Apple tech note, App Transport Security requires SHA-2. The S3 (and CloudFront) certificates are using SHA-1, which is why this failure is occurring.

The workaround is to set the NSExceptionRequiresForwardSecrecy to false. (This is until AWS moves to SHA-2 (by September 30th, 2015)).

SHA-1 Signature

HTTP load failed in xcode version 9.3 ios 11 even after adding temporary exception on plist file

Here's the code from the linked answer in Swift. HTH.

class RequestHelper: NSObject, URLSessionDelegate {
func makeRequest(request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) ->() ) {
let sessionConfiguration = URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfiguration, delegate: self, delegateQueue: nil)
let task = session.dataTask(with: request) { data, response, error in
completionHandler(data, response, error)
}
task.resume()
}

func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition,
URLCredential?) -> () ) {
guard
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
challenge.protectionSpace.host == "yourdomain.com",
let trust = challenge.protectionSpace.serverTrust
else {
return
}
let credential = URLCredential(trust: trust)
completionHandler(.useCredential, credential)
}
}

Making HTTPS request in iOS 9 with self-signed certificate

This issue was solved some time ago. It turned out to be invalid self-signed certificate. It didn't meet all requirements from Apple. Unfortunately i don't know, what exactly it was.



Related Topics



Leave a reply



Submit