gpt4 book ai didi

ios7 - 在 iOS 7 上绕过自签名证书的 kCFStreamErrorDomainSSL 错误

转载 作者:行者123 更新时间:2023-12-04 01:51:29 26 4
gpt4 key购买 nike

我正在尝试将具有自签名证书的 HTTPS 网页加载到 UIWebView 中。使用类似 this one 的提示, 或 this one ,它在 iOS 6 下工作。同样在 iOS 7 中不起作用。
根据链接到堆栈溢出的问题,我还使用 NSURLConnection 首先尝试通过自签名证书——这一切都是在尝试加载 UIWebView 中的 URL 之前完成的。
在 iOS 7 中尝试相同时,我收到以下错误:

2014-02-12 16:00:08.367 WebView[24176:5307] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

2014-02-12 16:00:08.370 WebView[24176:70b] An SSL error has occurred and a secure connection to the server cannot be made.


有没有办法让它在 iOS 7 中工作?目前我正在使用 first example .

最佳答案

请点击链接:

in UiWebView - NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -108)

BOOL _Authenticated;
NSURLRequest *_FailedRequest;
#pragma UIWebViewDelegate

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
BOOL result = _Authenticated;
if (!_Authenticated) {
_FailedRequest = request;
NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[urlConnection start];
}
return result;
}

#pragma NSURLConnectionDelegate

-(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
NSURL* baseURL = [NSURL URLWithString:@"your url"];
if ([challenge.protectionSpace.host isEqualToString:baseURL.host]) {
NSLog(@"trusting connection to host %@", challenge.protectionSpace.host);
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
} else
NSLog(@"Not trusting connection to host %@", challenge.protectionSpace.host);
}
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)pResponse {
_Authenticated = YES;
[connection cancel];
[webvw loadRequest:_FailedRequest];
}

关于ios7 - 在 iOS 7 上绕过自签名证书的 kCFStreamErrorDomainSSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21719240/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com