WKWebView not loads http image in iOS 10 and above

淺唱寂寞╮ 提交于 2019-12-13 15:49:57

问题


I am loading a https URL in WKWebView and inside that few images are coming from HTTP URL which is loading perfectly fine on enabling NSAllowsArbitraryLoads in info.plist file in iOS 9. But on iOS 10 and above it is not loading the HTTP images. I read Apple and followed all possible way but no luck.


回答1:


Add the below line in info.plist,

NSAllowsArbitraryLoadsInWebContent

and set its value as YES




回答2:


Allowing Insecure Connection to a Single Server

fetching media from an insecure server use below

NSAppTransportSecurity
    NSExceptionDomains
        "media-server.example.com"
            NSExceptionAllowsInsecureHTTPLoads = YES

Apple warnings

Important: Before implementing this exception, consider that a seemingly-benign network request can cause security problems of the sort that ATS is intended to mitigate. For example, fetching media from an insecure server entails the following risks, among others: An attacker can see the media file a user is accessing Your app’s attack surface expands, for example, by allowing a bad actor to feed your app a malicious file intended to trigger a buffer overrun Avoid this connection type if possible.

The App Transport Security (ATS) keys are:

  1. NSAllowsArbitraryLoads
  2. NSAllowsArbitraryLoadsForMedia
  3. NSAllowsArbitraryLoadsInWebContent
  4. NSExceptionAllowsInsecureHTTPLoads
  5. NSExceptionMinimumTLSVersion

You can get more info from NSAppTransportSecurity



来源:https://stackoverflow.com/questions/44795126/wkwebview-not-loads-http-image-in-ios-10-and-above

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!