1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 使用mPaas的H5容器加载tls有问题的https网页白屏的解决办法

使用mPaas的H5容器加载tls有问题的https网页白屏的解决办法

时间:2022-05-18 16:36:48

相关推荐

使用mPaas的H5容器加载tls有问题的https网页白屏的解决办法

1.给PSDWebViewURLProtocol添加分类

2.实现这个方法- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;

为什么不是- (void)connection:didReceiveAuthenticationChallenge:这个方法呢?

因为API_DEPRECATED("Use -connection:willSendRequestForAuthenticationChallenge: instead.", macos(10.2,10.10), ios(2.0,8.0), watchos(2.0,2.0), tvos(9.0,9.0));

3.

-(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{// 判断是否是信任服务器证书// if(challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) {// 告诉服务器,客户端信任证书// 创建凭据对象NSURLCredential *credntial = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];// 告诉服务器信任证书[challenge.sender useCredential:credntial forAuthenticationChallenge:challenge];// }}

注意:里面代码要写完整,判断了NSURLAuthenticationMethodServerTrust还要判断其他的

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。