0

Below snapshot has 2 wkwebviews in the iOS app. Upper part - wkvebview1: loads html page from locally hosted secure CocoaHTTPServer on port 51092. Lower part - wkvebview2: loads http url from locally hosted CocoaHTTPServer instance on port 51091.

Images loads fine in both wkwebviews. Not able to load video with secure webserver.

Is there any known limitation for wkWebview in iOS10 for video using secure webserver?

snapshot

Sample iPhoneHttpServer Github link

Anand
  • 1,440
  • 8
  • 11

1 Answers1

0

SSL/TLS security requires a certificate that's valid for your server's hostname; by default, a WebView will not load content from a TLS server that cannot present a valid certificate. This makes secure mode for the HttpServer class essentially useless, as iPhones do not have stable public hostnames, and it is impossible to obtain a valid certificate for localhost.

In any case, enabling secure mode on a server running locally is hardly necessary; traffic to that server is local to the device, and cannot be intercepted.

  • Thanks @duskwuff for quick response. With ATS enabled , http://localhost urls are blocked so I have no other option than to go with secure server implementation. Accessing local resources through file:// is not a good option for me. – Anand Oct 05 '16 at 19:48
  • A broader explanation of what you're trying to do would be helpful. There's probably a better way of going about it than running an HTTP server. –  Oct 05 '16 at 20:12
  • The goal we’re trying to accomplish is to load a local video asset (stored on disk) into a WKWebView instance, to be used as a texture in WebGL. Using file:// is not an option as that can not be used as texture in WebGL. Up until now, we have been accomplishing this using a server bound to localhost (GCDWebServer), and loading the local source code as an HTML string with (in this example,) baseURL:"http://localhost:51092/", and then playing the video with the following line of code: – Anand Oct 05 '16 at 20:30
  • Good. Now ask that as a new question. :) –  Oct 05 '16 at 20:52
  • :) Its up here already! http://stackoverflow.com/questions/39859724/openssl-server-not-receiving-requests-for-media-audio-video-from-wkwebview – Anand Oct 05 '16 at 22:07