在UIWebView中加载HTTPS url
我开始进行iPhone编程,并遇到很大的问题,无法解决。在UIWebView中加载HTTPS url
所以,我有一个UIWebview
,我可以加载HTTP网址没有问题:
NSString urlAdress;
urlAdress = @"http://servername";
NSURL *url = [NSURL URLWithString:urlAdress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
它的工作,我的页面加载在我的UIWebView,但是当我更换:
urlAdress = @"http://servername";
由
urlAdress = @"https://servername";
我有空白屏幕。
我读了它的正常,但有没有简单的方法来在我的webview中加载https url?
我读了ASIHTTPRequest
,但我没有达到实施它。
我只是想加载HTTPS URL。
试试这个:
- (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];
}
我只是将它添加到包含UIWebView的UIViewController?我不太确定该怎么做。 – powerj1984 2012-08-31 17:35:11
这两个方法是[NSURLConnectionDelegate](https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html)协议的一部分,因此您可以将它们放入任何文件充当您NSURLConnection的代表。 – 2012-10-12 14:10:58
我也在使用自己分配的证书,它与上面的实现一起工作。 – m4n1c 2013-04-03 06:01:32
会发生什么事,如果你加载'的https:// servername'在Safari? – deanWombourne 2011-06-10 14:05:09
在safari中我可以加载“http:// servername”和“https:// servername” – Borneto 2011-06-10 14:07:55
这是否带有自签名证书? – Jim 2011-06-10 16:53:03