如何在 iOS 中处理“CFNetwork SSLHandshake failed”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19922717/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to handle "CFNetwork SSLHandshake failed" in iOS
提问by Arun_
Some times i'm getting CFNetwork SSLHandshake failed -(9806)
in my code,but i'm not sure why this is happening as my code runs smoothly,except when i run it in iOS 6 and then on iOS 7 64-bit i get this warning.
Can anybody suggest me, how to handle this issue ?
有时我会进入CFNetwork SSLHandshake failed -(9806)
我的代码,但我不确定为什么会发生这种情况,因为我的代码运行顺利,除非我在 iOS 6 中运行它然后在 iOS 7 64 位上运行时我收到此警告。
任何人都可以建议我,如何处理这个问题?
采纳答案by JoshK
Normally when I get CFNetwork SSLHandshake failed -(*)
Its because of my local wifi network (device is connected to network but notthe internet)
通常,当我得到CFNetwork SSLHandshake failed -(*)
,因为我的本地WiFi网络的ITS(设备连接到网络,但没有互联网)
Try it again on another network (3G is the quickest solution for me)
在另一个网络上再试一次(3G 对我来说是最快的解决方案)
回答by Antoine
This could also happen because of iOS 9. iOS 9 and OSX 10.11 require TLSv1.2 SSL for all hosts you plan to request data from unless you specify exception domains in your app's Info.plist file.
这也可能因 iOS 9 而发生。iOS 9 和 OSX 10.11 要求您计划从中请求数据的所有主机使用 TLSv1.2 SSL,除非您在应用程序的 Info.plist 文件中指定异常域。
You can find more info here: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/
您可以在此处找到更多信息:https: //developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/
Or Steven Peterson's answer here, which is quite clear: https://stackoverflow.com/a/30720929/1485701
或者史蒂文彼得森在这里的回答,这很清楚:https: //stackoverflow.com/a/30720929/1485701
回答by OhadM
Had the same issue and after I have confirmed that the server is getting the POST the solution was this:
有同样的问题,在我确认服务器正在获取 POST 后,解决方案是这样的:
- Clean the project: Product -> Clean
- Delete your app from the iOS device/iOS Simulator and quit the Simulator
- Compile your app and run it
- 清理项目:产品 -> 清理
- 从 iOS 设备/iOS 模拟器中删除您的应用程序并退出模拟器
- 编译您的应用程序并运行它
In my case, simple as that.
就我而言,就这么简单。
回答by user1015777
I had the same problem, and in my case the solution was that in my code I wrote
我遇到了同样的问题,就我而言,解决方案是在我编写的代码中
initWithScheme:@"https"
instead of
代替
initWithScheme:@"http"
So make sure you use the correct protocol
所以请确保您使用正确的协议
回答by mramonlopez
Another solution: check if date/time is set correctly in your phone. SSL certificates are valid UNTIL certain date.
另一种解决方案:检查手机中的日期/时间设置是否正确。SSL 证书在特定日期之前有效。