在UiWebView – NSURLConnection / CFURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-108)
当我在UIWebView中打开一个链接,并点击该网站的内容的Facebook图标时,它会给出以下错误
2014-01-09 13:15:14.412 AppName[2067:5407] CFNetwork SSLHandshake failed (-108) 2014-01-09 13:15:14.412 AppName[2067:5407] CFNetwork SSLHandshake failed (-108) 2014-01-09 13:15:15.063 AppName[2067:5407] CFNetwork SSLHandshake failed (-108) 2014-01-09 13:15:15.064 AppName[2067:5407] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -108)
我也在谷歌search这个错误但没有find-108的结果。 98 *的search结果。
和这个相同的链接相同的过程在safari和其他应用程序的UIWebView。 但我把第二个应用程序的新项目,把这个链接在UIWebView,它给错误。
请帮助,并提前致谢。
如果你把它放在你的代码中的任何地方,应用程序将绕过证书validation:
@implementation NSURLRequest(DataController) +(BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host { return YES; } @end
Facebook在URL中有https
协议。
在UIWebview
中加载https
url与加载普通的https
url不同。
并加载https
url,请看看加载-http-url-in-uiwebview和这SOpost1和SOpost2在这里。
它可以帮助你。
我想你正试图find这个:
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]; }