当我在UIWebView中打开一个链接并点击该URL内容的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)
我也在谷歌中搜索此错误但未找到 -108 的结果。结果发现 98 *
和相同的链接相同的过程在safari和其他应用程序UIWebView中工作。 但我为第二个应用程序采用了新项目并将此链接放在UIWebView中,它给出了错误。
请提前帮助和致谢。
答案 0 :(得分:3)
Facebook在网址中有 https
协议。
在https
中加载 UIWebview
网址与加载普通 https
网址不同。
要加载 https
网址,请在此处查看loading-https-url-in-uiwebview以及此SO Post 1和SO Post 2。
它可能对你有帮助。
答案 1 :(得分:-1)
我想你是想找到这个:
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];
}