|
@@ -247,14 +247,20 @@
|
|
|
|
|
|
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *_Nullable))completionHandler
|
|
|
{
|
|
|
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
|
|
- if (challenge.previousFailureCount == 0) {
|
|
|
- NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
|
|
|
- completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
|
|
|
- } else {
|
|
|
+ dispatch_queue_t queue = dispatch_queue_create("webViewChallengeQueue", NULL);
|
|
|
+ dispatch_async(queue, ^{
|
|
|
+ if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
|
|
+ if (challenge.previousFailureCount == 0) {
|
|
|
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
|
|
|
+ completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
|
|
|
+ } else {
|
|
|
+ completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
#pragma mark - WKScriptMessageHandler
|
|
|
- (void)userContentController:(WKUserContentController *)userContentController
|