如何解决"CFNetwork SSLHandshake failed (-9806)"



我正在尝试修复CFNetwork SSLHandshake失败(-9806)警告。我的应用程序运行良好,但是当我在设备中通过Xcode运行应用程序时,应用程序崩溃。我在 .plist 中添加了 NSAppTransportSecurity,

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>yourserver.com</key>
    <dict>
      <!--Include to allow subdomains-->
      <key>NSIncludesSubdomains</key>
      <true/>
      <!--Include to allow insecure HTTP requests-->
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <!--Include to specify minimum TLS version-->
      <key>NSExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
    </dict>
  </dict>
</dict>

还测试了不同的3G/wifi。

需要帮助。提前谢谢。

浏览此链接

还可以尝试使用不同版本的 TLS,如下所示。

<key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.1</string>

还可以通过添加到应用的 Info.plist 来检查这一点:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>YOUR_HOST.COM</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>1.0</string>
            <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
    </dict>
</dict>

我也有同样的问题。在阅读了这篇文章CFNetwork SSLHandshake失败的iOS 9之后,我把它放在Info.plist上,现在可以工作了:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

最新更新