Enable encrypted DNS for WKWebView from in-process configuration

Originator:stone33.mail
Number:rdar://FB9960361 Date Originated:17.03.2022
Status:Open Resolved:
Product:Network Framework Product Version:
Classification:Suggestion Reproducible:
 
When I enable encrypted DNS only for my process using shared privacy context, it doesn't apply to WKWebView since its networking takes place in separate processes. However web content still corresponds to the specific app and it would be great that the same encrypted DNS configuration should be used for WKWebView instances created by the application.
It is way better than applying system-wide configuration only to workaround this issue.

Code:

import Network

   if #available(iOS 14, *) {
     if let url = URL(string: "https://dns-family.adguard.com/dns-query") {
       NWParameters.PrivacyContext.default.requireEncryptedNameResolution(true,
           fallbackResolver: .https(url, serverAddresses: [
             NWEndpoint.hostPort(host: "2a10:50c0::bad1:ff", port: 443),
             NWEndpoint.hostPort(host: "2a10:50c0::bad2:ff", port: 443),
             NWEndpoint.hostPort(host: "94.140.14.15", port: 443),
             NWEndpoint.hostPort(host: "94.140.15.16", port: 443),
           ]))
     }
   }

https://developer.apple.com/videos/play/wwdc2020/10047/

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!