iOS9 does not load insecure resources from a secure page (SSL/HTTPS)

后端 未结 6 924
旧时难觅i
旧时难觅i 2020-11-27 04:33

I am trying to load a page into UIWebView on iOS9 using https:// URL. The page loaded includes CSS and images from an insecure server.

E.g. the page loaded:

6条回答
  •  我在风中等你
    2020-11-27 05:13

    Below procedure enable me to open not secure content in WKWebView.

    1. First I added Allow Arbitrary Loads in Web Content = YES and Allow Arbitrary Loads = YES in App Transport Security Settings dictionary in info.plist.
    2. I have added below wkwebview delegate method:

      func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!)) }

      For 2nd step don't forget to register delegate as:

      override func viewDidLoad() { super.viewDidLoad() self.webView.navigationDelegate = self }

提交回复
热议问题