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}
There's nothing real special happening here. I'm just trying to mimic Safari.
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)
}
It's worth noting that didReceive challenge
isn't called when redirecting.
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).
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.
What am I missing?