1.首先需要设置代理
_wkWebView.UIDelegate = self;
2.实现该代理方法
- (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 {
completionHandler(NSURLSessionAuthChallengeUseCredential, nil);
}
} else {
completionHandler(NSURLSessionAuthChallengeUseCredential, nil);
}
}
截止目前wkwebview就可以加载不被信任的https界面了
博客介绍了让WKWebView加载不被信任的HTTPS界面的方法,首先要设置代理,然后实现该代理方法,完成这两步即可达成目的。
3940

被折叠的 条评论
为什么被折叠?



