UIWebView无法打开我的HTTPS URL

时间:2013-06-25 18:46:49

标签: iphone ios sdk uiwebview ios6.1

我想用UIWebView打开一个HTTPS网址。我已经添加了allowsAnyHTTPSCertificateForHost的代码。这是我NSURLRequest的一个简单请求,它似乎很成功,但在我的iPhone中显示的不是。

当我尝试使用我的3g连接时,会显示以下日志:

void SendDelegateMessage(NSInvocation *): delegate(webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: _kCFURLConnectionPrivateRunLoopMode

我尝试添加几个代码,但没有一个有效:

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
    return YES;
}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}

@implementation NSURLRequest (NSURLRequestWithIgnoreSSL)

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

@end

有关正在发生的事情的任何想法?我错过了什么吗?

0 个答案:

没有答案