Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoSelectCertificateForUrls for Chrome works ONLY in non-headless mode

I am auto-selecting a certificate for Chrome on MacOS using the following preference file:

<plist version="1.0″>
<dict>
  <key>AutoSelectCertificateForUrls</key>
   <array>
     <string>{"pattern":"[*.]my.url.net","filter":{"ISSUER":{"CN":"CERT CA"}}}</string>
   </array>
</dict>
</plist>

It works great, but when I try to run my tests on Chrome using headless mode it doesn't seem to auto-select the certificate.

Does anyone know how to get to this to work? I am using the following ChromeOptions:

'chromeOptions': {
      'args': ['--ignore-certificate-errors', '--headless', '--disable-gpu', '--no-sandbox']
}
like image 456
OhWhenELC Avatar asked Aug 31 '25 01:08

OhWhenELC


1 Answers

Policy configuration is not supported by headless chrome, if headless firefox is an option you can use fireFoxOptions to use profiles where you can add certificates. I needed to auto select certificates and manage to do it only with headless firefox. Open default firefox, setup your profile and then point to it on code if you dont want to do it manually.

FirefoxOptions options = new FirefoxOptions();
FirefoxProfile firefoxProfile = new FirefoxProfile(@"C:\Users\....\AppData\Roaming\Mozilla\Firefox\Profiles\...default");
options.Profile = firefoxProfile;
like image 78
Cadudragon Avatar answered Sep 02 '25 16:09

Cadudragon