Reputation: 389
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?
Upvotes: 1
Views: 19894
Reputation: 805
Solution:
We have to enabled Proxy in NSURLSession request as following :
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.timeoutIntervalForRequest = 60;
/* To Fixed AIRWatch SDK Issue in API Calling */
// Create an NSURLSessionConfiguration that uses the proxy
NSDictionary *proxyDict = @{
@"HTTPEnable" : [NSNumber numberWithInt:1],
@"HTTPSEnable" : [NSNumber numberWithInt:1],
};
configuration.connectionProxyDictionary = proxyDict;
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue mainQueue]];
Please made above changes in your source code. It will resolve your issue.
Upvotes: 3
Reputation: 389
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.
Upvotes: 4