【问题标题】:in UiWebView - NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -108)在 UiWebView - NSURLConnection/CFURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-108)
【发布时间】:2014-01-27 16:09:15
【问题描述】:

当我在 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)

我也在 google 中搜索过这个错误但是没有找到 -108 的结果。 98*

的结果

这个相同的链接同样的过程在 safari 和其他应用程序 UIWebView 中也有效。 但我将新项目用于第二个应用程序并将此链接放在 UIWebView 中,它给出了错误。

请提前帮助和感谢。

【问题讨论】:

  • 你在多个设备上测试过这个吗?它也发生在你的模拟器中吗?
  • 是的,我也在两个设备和模拟器中测试它。但不要在任何设备或模拟器中工作。'
  • 你能发布一些与在 WebView 中加载链接相关的代码吗?还是示例项目?

标签: ios objective-c facebook ipad uiwebview


【解决方案1】:

如果您将其放在代码中的任何位置,应用程序将绕过证书验证:

@implementation NSURLRequest(DataController)

+(BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}

@end

【讨论】:

  • 这是一个私有 API,可能会导致应用商店审核期间被拒绝。
  • 仅用于调试目的。
【解决方案2】:

Facebook 在 URL 中有 https 协议。

UIWebview 中加载 https url 与加载普通 https url 不同。

要加载 https URL,请在此处查看 loading-https-url-in-uiwebview 以及此 SO Post 1SO Post 2

也许对你有帮助。

【讨论】:

    【解决方案3】:

    我认为您正在尝试找到这个:

    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];
    }
    

    【讨论】:

      猜你喜欢
      • 2015-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-24
      • 2015-09-04
      • 1970-01-01
      • 2014-12-23
      • 1970-01-01
      相关资源
      最近更新 更多