環境 xCode8 iOS10 操做:新浪微博的第三方登陸php
error = Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9824, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?
發生了 SSL 錯誤,沒法創建與該服務器的安全鏈接ios
在info.plist 中添加如下代碼,但沒有解決問題git
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> </true> </dict>
nscurl --ats-diagnostics --verbose https://xxx.com 出現問題的URL,在服務端上配置TLSV1.2github
✗ nscurl --ats-diagnostics --verbose https://api.xxx.com/oauth2/authorize\?client_id\=xxxxxx\&redirect_uri\=http://www.xxx.com/data/api/oauth/connect.php\?method\=weibo_callback\&response_type\=code\&state\=weibo_58247803463a94.25994144 Starting ATS Diagnostics Configuring ATS Info.plist keys and displaying the result of HTTPS loads to https://api.weibo.com/oauth2/authorize?client_id=1681325651&redirect_uri=http://www.guojishitiao.com/data/api/oauth/connect.php?method=weibo_callback&response_type=code&state=weibo_58247803463a94.25994144. A test will "PASS" if URLSession:task:didCompleteWithError: returns a nil error. ================================================================================ Default ATS Secure Connection --- ATS Default Connection ATS Dictionary: { } 2016-11-10 21:50:17.832 nscurl[37466:1493984] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9801) Result : FAIL <--問題 》》 在服務端 Nginx上配置TLSV1.2,支持ATS
*** 因爲iOS10的發佈,原有ATS設置在iOS10上會出現https網絡訪問限制的問題。***api
<key>sina.com.cn</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict>
須要在問題域名下添加NSExceptionMinimumTLSVersion 的key,值設置爲TLSv1.0安全
== 網絡