0

I have read many questions/answers to this similar problem but unfortunately none of them worked for me. I have a link (cannot be disclosed here for NDA purposes) that is a https but unable to load in my UIWebview. It however loads fine in Safari/Chrome in desktop. The code I use to load it:

NSURL *url = [NSURL URLWithString:@"https://xxx.xxx.xxx/disclaimer.html"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [_myWebView loadRequest:request];

What I tried: I tried loading other https link, (https://www.google.com), it works ok (Google page loaded). But only my particular https is not loading in the webview. I have no idea what else to try so if you have idea what is going on, pls share.

ERROR Log says it's timed out.

Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."

GeneCode
  • 7,545
  • 8
  • 50
  • 85
  • So what's the output of the console? If other HTTPS are working ok, then it's probably your site's fault (maybe you need to login before loading anything?). – Alejandro Iván Jun 23 '17 at 04:34
  • Added the error. Basicaly a timed out. The same link can be opened in Safari and no login needed. It is basically a simple disclaimer page. – GeneCode Jun 23 '17 at 04:37
  • How much time does it take to load the page in Safari? Did you try to change the timeout in `NSURLRequest`? And clearing Safari cache? – Alejandro Iván Jun 23 '17 at 04:39
  • In Safari the page loaded instantly. I didnt mess with timeout, that 3 lines of code is all of it in viewDidLoad of my app. – GeneCode Jun 23 '17 at 04:40
  • Try loading it in private mode in Chrome for iOS to avoid caching. – Alejandro Iván Jun 23 '17 at 04:42
  • Another thing that comes to my mind would be a self-signed SSL certificate. https://stackoverflow.com/questions/11573164/uiwebview-to-view-self-signed-websites-no-private-api-not-nsurlconnection-i avoids the SSL checks, that **could** be the source of your problem but I'm not really sure. – Alejandro Iván Jun 23 '17 at 04:48
  • Check if your site serves all intermediate certificates. You can use an online scanner such as SSL Labs for this. – Anand Bhat Jun 23 '17 at 20:49

1 Answers1

0

Just for my case, it appears that the URL is only accessible on simulator since my macbook was connected to the LAN. (URL was only LAN limited). I got mixed results and made me confuse because apparently the UIWebview keeps a cache of the website so subsequent access to it via the wifi makes it available (when in fact it is not).

In short, my problem was not caused by http nor https or any certs related issues. It is merely availability of the URL thru internet/intranet issue.

GeneCode
  • 7,545
  • 8
  • 50
  • 85