Reputation: 11
I am pretty new to using Selenium and it's webdrivers. I have a need to enable DoH (dns over https) together with an option for selecting which DoH server to connect to in chrome driver in Selenium.
I have been researching online and have gone through recommended switches available here: https://peter.sh/experiments/chromium-command-line-switches/ as well as seen a similar post here: How to disable dns over https in selenium for disabling DoH (I don't even have DoH enabled by default in first place in chromedriver), but haven't figured out yet to how to get it enabled in the headless mode.
I also looked at the switches available for firefox driver but still don't see any right away available switches to use for the same.
Any help would be appreciated.
Thanks! fbw
Upvotes: 1
Views: 1229
Reputation: 1424
To enable DoH you need to do the following:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
local_state = {
"dns_over_https.mode": "automatic",
"dns_over_https.templates": "",
}
options = Options()
options.add_experimental_option('localState', local_state)
driver = webdriver.Chrome(options=options)
This will turn on the DoH which looks like this in browser settings on the chrome://settings/security page:
Also you can set "dns_over_https.mode": "automatic"
which will set the secure option of DoH configuration:
Unfortunately I failed to figure out ho to use "dns_over_https.templates": ""
. Documentation says about it:
String containing a space-separated list of DNS over HTTPS templates to use in secure mode or automatic mode. If no templates are specified in automatic mode, we will attempt discovery of DoH servers associated with the configured insecure resolvers.
I'm not familiar with DoH, so this description tells me nothing. I don't know what a DoH template is. I hope you know what they are talking about.
Upvotes: 3