After starting using Xcode 13 beta(1 and 2) and iOS15 simulators we realized that we can't connect to our internal servers using https connection with self-signed certificate. We are receiving
NSUnderlyingError=0x600003f91e30 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x6000000f4e60>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802
At the moment we don't have any devices with iOS15 beta installed on them and couldn't confirm if issue reproduced there as well but using simulator or real devices with prior versions of iOS works without any issues and we are not sure if it's a bug in iOS15 beta builds or some new security restrictions for SSL/TLS connections or trusted connections. We are using certificate pinning(and including and using root certificate) and couldn't see any issues while validating SecTrust object after receiving challenge inside URLSessionDelegate
let host = challenge.protectionSpace.host
guard challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
let trust = challenge.protectionSpace.serverTrust
else {
completionHandler(.performDefaultHandling, nil)
return
}
let policy = SecPolicyCreateSSL(true, host as CFString)
let status = SecTrustSetPolicies(trust, policy)
let pinCertificate = SecTrustSetAnchorCertificates(trust, certificates as CFArray)
let onlyStatus = SecTrustSetAnchorCertificatesOnly(trust, true)
var error: CFError?
let isValidationSuccessful = SecTrustEvaluateWithError(trust, &error)
if isValidationSuccessful {
completionHandler(.useCredential, URLCredential(trust: trust))
} else {
completionHandler(.cancelAuthenticationChallenge, nil)
}
Could someone clarify next questions:
- What does 9802 error code actually mean? i found that it some kind of generic fatal error but it isn't useful information
- Are there any new restrictions for self signed certificates or ssl/tls connections that will be introduced in iOS15?