美文网首页
KWWebView与https的激情

KWWebView与https的激情

作者: 斌小狼 | 来源:发表于2021-05-25 15:33 被阅读0次

最近收到了个新的需求,电脑自己开一个服务(https协议)。手机端使用webView加载呈现。

而在实现时遇到了:Https服务器证书无效 code = -1202


Log

最后决定不验证证书先做实现与测试:

//WKWebView与UIWebView代理不同,需使用NSURLConnectionDelegate
@interface ViewController ()<WKNavigationDelegate,NSURLConnectionDelegate>

#pragma mark -- NSURLConnectionDelegate
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler{

    NSURLCredential *card = [[NSURLCredential alloc] initWithTrust:challenge.protectionSpace.serverTrust];
    completionHandler(NSURLSessionAuthChallengeUseCredential,card);
}

做个记录

相关文章

网友评论

      本文标题:KWWebView与https的激情

      本文链接:https://www.haomeiwen.com/subject/vmfcsltx.html