kCFErrorDomainCFNetwork 代码=310“(空)"; [英] kCFErrorDomainCFNetwork Code=310 "(null)"

查看:18
本文介绍了kCFErrorDomainCFNetwork 代码=310“(空)";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 WKWebView 连接到一个站点,根据用户的选择,该站点将重定向到另一个站点.didReceiveServerRedirectForProvisionNavigation 之后出现以下错误:

Using a WKWebView, connect to a site that, upon user selection, will redirect to another site. The following error comes up after didReceiveServerRedirectForProvisionNavigation:

Error Domain=kCFErrorDomainCFNetwork Code=310 "(null)" UserInfo={_WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x60800002a8e0>, _kCFStreamErrorCodeKey=-2096, _kCFStreamErrorDomainKey=4}

这里没有什么特别的事情发生.我只是想模仿 Safari.

There's nothing real special happening here. I'm just trying to mimic Safari.

我还使用以下内容覆盖了 didReceive Challenge:

I've also overridden didReceive challenge with the following:

func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) ->     Void) {
    var cred: URLCredential?
    if let trust = challenge.protectionSpace.serverTrust {
        cred = URLCredential(trust: trust)
    } else {
        //creds are hardcoded just to try to get the thing working.
        cred = URLCredential(user: "hardcodedusername", password: "hardcodedpassword", persistence: .permanent)
    }
    completionHandler(.useCredential, cred)
}

值得注意的是,重定向时不会调用didReceive Challenge.

It's worth noting that didReceive challenge isn't called when redirecting.

我的假设是我尝试重定向到的站点具有旧的加密协议 (TLS 1.0),而 iOS 不允许重定向.该网站在 iPhone 上的 Safari 中运行良好.我还设置了 ATS 任意负载.这是Objective-C到Swift的转换,Objective-C版本没有这个问题(使用UIWebView,这是我在尝试WKWebView之前的原始实现......同样的错误).

My assumption is that the site that I'm trying to redirect to has an old encryption protocol (TLS 1.0) and iOS isn't allowing the redirect. The site works fine in Safari on the iPhone. I also have ATS arbitrary loads set. This is Objective-C to Swift conversion, and the Objective-C version has no problem with this (using UIWebView, which was my original implementation before trying WKWebView... same error).

明确地说,这是一个 QA 环境.我不在乎证书是好是坏.如果我能避免这种环境的任何安全要求就好了,但似乎任意负载设置对我没有任何作用.

To be clear, this is a QA environment. I don't care if the cert is good or bad. If I can avoid any security requirement for this environment that would be great, but it seems like the arbitrary load setting doesn't do anything for me.

我错过了什么?

推荐答案

当前的解决方案是关闭 TLS 1.0.如果有人提出更好的答案,请更新.听起来 Apple 没有解决这个问题的内置方法.

Current solution is to turn off TLS 1.0. If anyone comes up with a better answer, please update. Sounds like Apple doesn't have a built in way to get around this problem.

这篇关于kCFErrorDomainCFNetwork 代码=310“(空)";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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