UIWebView won't load links with certificate (https:// prefix)
Asked Answered
L

2

5

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

Lapoint answered 25/3, 2011 at 1:3 Comment(0)
L
2

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];
Lapoint answered 19/4, 2011 at 2:8 Comment(2)
This is a pretty bad solution. You are basically loading the pages twice now. Once with the ASIHTTPRequest and once with the UIWebView.Nalepka
Loading pages twice is actually the only way anybody seems to be able to load HTTPS in later versions of iOS. It's a hairy mess.Readymix
Z
0

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
        }
    }
Zymase answered 23/5, 2016 at 8:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.