Yesterday we ran into a strange behavior with ATS and NSURLSession. We have a macOS application which connects to an internal network webservices over HTTPS using NSURLSession. Recently we have disabled ATS entirely via NSAllowsArbitraryLoads to "true" in Info.plist file.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Now when users of this application trying to connect the webservice are getting connection errors. Now the strange part is not all of the users are seeing this error. They have different versions of 10.11.x. A user with 10.11.6 sees a problem and another user with same OS version doesn't.
I am baffeled as to what external behavior/parameters controlling the NSURLSession besides ATS and why this behavior changes per machines? I suspected HSTS so I deleted the HSTS.plist file but no use (not sure if that is the right file, but it is used by Safari). I have verified ATS to be working by verifying the the ciphers offered by the clients in Client Hello. We delegate the trust evaluation and override the system defaults procedure with our own trusted anchors and it passes without any issue.
NSURLSession failed with error: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrust 0x7fa4c4d15ea0 [0x7fff7a2b4440]>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, NSErrorPeerCertificateChainKey=(
"<SecCertificate 0x7fa4c4d214d0 [0x7fff7a2b4440]>"
), NSUnderlyingError=0x7fa4c2420b80 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFNetworkCFStreamSSLErrorOriginalValue=-9802, kCFStreamPropertySSLPeerCertificates=(
"<SecCertificate 0x7fa4c4d214d0 [0x7fff7a2b4440]>"
), _kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrust 0x7fa4c4d15ea0 [0x7fff7a2b4440]>, _kCFStreamPropertySSLClientCertificates=(
"<SecIdentity 0x7fa4c4d14c90 [0x7fff7a2b4440]>",
"<SecCertificate 0x7fa4c2425660 [0x7fff7a2b4440]>"
), _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802}}, NSErrorClientCertificateChainKey=(
"<SecIdentity 0x7fa4c4d14c90 [0x7fff7a2b4440]>",
"<SecCertificate 0x7fa4c2425660 [0x7fff7a2b4440]>"
), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.,I have verified the server to be ATS complaint by running "nscurl --ats-diagnostics", TLSTool and also attempted to debug the logs by setting CFNETWORK_DIAGNOSTICS but not much fruitful came out of it. Now, I am ran out of ideas, so need help.
Thanks in advance.