UIWebView 不会加载带有证书的链接(https:// 前缀)

发布于 2024-10-26 14:26:30 字数 1520 浏览 7 评论 0原文

我知道以前曾有人问过这个问题,但我已经查看了每个答案(数量不多),但没有一个对我有帮助。

我遇到的问题是使用学校电子邮件服务处理证书。两个电子邮件服务的链接如下:

主要学校电子邮件: https://marauder.millersville.edu/mail/index.pl

计算机科学与技术-邮件: https://cs.millersville.edu/cswebmail

大学学生门户(右侧的掠夺者邮件按钮不在我的 UIWebView 中单击时无法打开)
http://myville.millersville.edu/

起初,这两个网站都不会使用标准 NSURL 和 NSURLRequest。我看了 在网上寻找解决方案,有人建议使用 NSURLProtocolClient 委托方法。后 实现它们后,我的 UIWebView 现在只会在我有一个按钮时加载学​​校邮件电子邮件 单击直接打开链接,而不是尝试从门户网站访问邮件(上面的第三个链接),并且它 仍然从未加载计算机科学电子邮件链接。我浏览了 iOS 帮助网站,发布了问题,尝试过 多个开源自定义 UIWebView,但我还没有找到任何有效的东西。

我在网上读到的大多数答案都指向 ASIHTTPRequest。我已经尝试过这个,但我无法正确实现它,它不会加载我的 UIWebView 中的链接;这是我如何加载链接的代码:

mURL = [self getURL:viewNumber];
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:mURL];
[req setDelegate:self];
[req startSynchronous];

//NSURLRequest *req = [NSURLRequest requestWithURL:mURL];
//urlConnection=[[NSURLConnection alloc] initWithRequest:req delegate:self];
webView.scalesPageToFit = YES;
//[webView loadRequest:req];

注释中的代码是我如何在没有 ASIHTTPRequest 的情况下加载链接的方式。

任何帮助表示赞赏!

另外,我的 UIWebView 还有另一个问题,链接如下。我还没有得到任何答案,所以如果你觉得无聊,请查看一下: UIWebView 未检测到网站上的文本框

I know this has been asked before but I have looked at every answer (there aren't many) and none help me.

The issue I am running into is dealing with certificates with my schools e-mail service. The links for the two e-mail services are here:

Main school e-mail:
https://marauder.millersville.edu/mail/index.pl

Computer Science e-mail:
https://cs.millersville.edu/cswebmail

University student portal (Marauder Mail button on the right doesn't open when clicked in my UIWebView)
http://myville.millersville.edu/

At first neither of the websites would load in my UIWebView using a standard NSURL and NSURLRequest. I looked
on the web for a solution and someone suggested using the NSURLProtocolClient delegate methods. After
implementing them, my UIWebView will now load the schools mail e-mail ONLY when I have a button that when
clicked opens the link directly, as opposed to trying to access the mail from the portal site (3rd link above), and it
still never loads the computer science e-mail link. I have scoured the iOS help sites, posted questions, tried
multiple open-source custom UIWebViews, but I have not found anything that works.

Most answers I have read around the web point to ASIHTTPRequest. I have tried this but I cannot implement it right, it doesn't load the links in my UIWebView; here is my code for how I am loading a link:

mURL = [self getURL:viewNumber];
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:mURL];
[req setDelegate:self];
[req startSynchronous];

//NSURLRequest *req = [NSURLRequest requestWithURL:mURL];
//urlConnection=[[NSURLConnection alloc] initWithRequest:req delegate:self];
webView.scalesPageToFit = YES;
//[webView loadRequest:req];

Code in comments is how I load a link without ASIHTTPRequest.

Any help is appreciated!

Also, I have another issue with my UIWebView, link is below. I haven't had any answers so if you're bored please check it out:
UIWebView doesn't detect text box on website

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼中杀气 2024-11-02 14:26:30

解决了我的问题,我能够使用以下代码毫无问题地加载 https,我认为这不起作用,但它确实有效!:

NSURLRequest *req = [NSURLRequest requestWithURL:mURL];
urlConnection=[[NSURLConnection alloc] initWithRequest:req delegate:self];
webView.scalesPageToFit = YES;
[webView loadRequest:req];

Fixed my issue, I was able to load https with no problem with the following code I didn't think this would work but it does!:

NSURLRequest *req = [NSURLRequest requestWithURL:mURL];
urlConnection=[[NSURLConnection alloc] initWithRequest:req delegate:self];
webView.scalesPageToFit = YES;
[webView loadRequest:req];
乙白 2024-11-02 14:26:30

由于证书不匹配,Web 视图不会加载 https url。编写此扩展后,它将按预期工作

斯威夫特2.2

  extension NSURLRequest {
        static func allowsAnyHTTPSCertificateForHost(host: String) -> Bool
        {
            return true
        }
    }

Web view does not load https urls due to certificate mismatch. After writing this extension it would work as expected

Swift 2.2

  extension NSURLRequest {
        static func allowsAnyHTTPSCertificateForHost(host: String) -> Bool
        {
            return true
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文