ios - 在 UIWebView 中加载 HTTPS url

标签 ios url https uiwebview asihttprequest

我开始 iPhone 编程,但遇到了无法解决的大问题。

所以,我有一个 UIWebview,我可以毫无问题地加载 HTTP url:

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

关于ios - 在 UIWebView 中加载 HTTPS url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6307400/

相关文章:

php - Http URL 保护在本地主机上有效,但在服务器上失败

java - 进行 HTTPS 调用时出现 NullPointerException

javascript - Angular templateUrl 在 https "This request has been blocked; the content must be served over HTTPS."上被阻止

ios - +初始化中的内存泄漏

ios - 如何将 CAShapeLayer 的路径平滑地动画到另一条路径?

asp.net - 如何使用代码隐藏技术在asp.net中获取当前页面的Url?

javascript - 如何通过 LInkedin 分享消息

ios - 如何在单独的 View 上显示 UIWebView 和实际 UIWebView 的加载进度?

ios - 当你调用 UItableview reload 两次时会发生什么

java - 使用HTTPS客户端向服务器的440端口发送请求