我想用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
有关正在发生的事情的任何想法?我错过了什么吗?