WKWebView 支持https请求

- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler {

    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);   

        

    }

}

原文地址:https://www.cnblogs.com/nyqmayi/p/7472575.html