问题
I'm having trouble with making a connection to an API over HTTPS/SSL. I've completely disabled App Transport Security (ATS) using the below dictionary (despite the fact that the SSL certificate passes all the tests from NSCURL).
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</plist>
BUT: There's still an SSL Handshake error (below) that, when Googled, only suggests it's to do with App Transport Security.
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
I've created a minimal sample project that demonstrates the issue, available on GitHub (https://github.com/samheather/AppTransportSecurityDemo). You should find that on running the project it crashes within a couple of seconds (straight after it tries to make the connection in viewDidLoad).
The domain that I'm trying to connect to is https://demo.heather.sh, and a sample URL that the certificate that has a response (so the certificate can be viewed) is https://demo.heather.sh:443/checkOnline.
Any ideas anyone?
Thanks!
Sam
回答1:
As described on iOS App Transport Security not accepting TLSv1.2 connection and plist exceptions not making any difference, the issue was that the server wasn't serving the certificate combined with the Intermediate certificate. Now that this is fixed, everything works :)
As Anand (above) says, a great tool to check this is: http://ssllabs.com/ssltest/analyze.html?d=
来源:https://stackoverflow.com/questions/36208890/app-transport-security-disabled-and-still-getting-ssl-handshake-error