HTTP加载失败(kCFStreamErrorDomainSSL,-9806(IOS9) [英] HTTP load failed (kCFStreamErrorDomainSSL, -9806 ( IOS9)

查看:631
本文介绍了HTTP加载失败(kCFStreamErrorDomainSSL,-9806(IOS9)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在模拟器上运行应用程序时,iOS 9上的NSURLSession/NSURLConnection HTTP加载失败. 这是我的info.plist文件的样子

I am getting the NSURLSession/NSURLConnection HTTP load failed on iOS 9 while running app on Simulator. Here is how my info.plist file looks like

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSIncludesSubdomains</key>
        <true/>
        <!--Include to allow insecure HTTP requests-->
        <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <!--Include to specify minimum TLS version-->
        <key>NSTemporaryExceptionMinimumTLSVersion</key>
        <string>TLSv1.1</string>
    </dict>

即使在输入了这些键值之后,Xcode控制台上仍显示相同的错误.请协助.

Even after entering these key values Same error is showing up on the Xcode Console. please assist.

这是 info.plist

非常感谢!

推荐答案

您需要定义要应用这些规则的URL. 您可以在Apple的文档页面上找到正确的声明: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

You need to define the URL you want to apply these rules for. You can find the correct declaration on Apple's documentation page: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

因此,基本上,您的Info.plist应该看起来像这样,并包含域.

So basically your Info.plist should look like this and include the domain.

注意:为了提高透明度,我还宣布NSAllowsArbitraryLoads的默认值为false

Note: for better transparency, I also redeclared the default value for NSAllowsArbitraryLoads to be false

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <false/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>yourdomain.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

最诚挚的问候.

以防万一,您只是不关心所有这些ssl混乱(我不建议您这样做),并且只想调试您的UI,也可以暂时转到非默认状态,对App TransportSecurity和只允许任何内容:

In case, you just don't care about all these ssl mess ups (I do not recommend this) and want to only go for debugging your UI, you can alternatively go temporarily and use the non-default for App TransportSecurity and allow just anything:

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

我不确定Apple是否会在AppStore评论中让它通过;-)

I am not sure, whether Apple would let this pass in the AppStore Review ;-)

这篇关于HTTP加载失败(kCFStreamErrorDomainSSL,-9806(IOS9)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆