0

When going to a specific site and logging in, it then requires me (through a prompt which I can't access the web elements of) to validate it using a specific certificate to authenticate myself. The certificate itself already appears to be loaded but the issue is just submitting / clicking the "Ok" response.

So, I've tried looking online and there does appear to be answers but they conflict with me. I'm running Chrome in headless mode which doesn't allow me to use the autoit or pyautogui libs. I have the certificate itself in my Keychain and also within my VSCode but not sure how I'd supply that to my driver to perhaps get rid of that prompt.

Here's a portion of my code:

def webdriverSetup():
    chrome_options = Options()
    #chrome_options.add_argument('--headless')
    chrome_options.add_argument("--window-size=1920,1080")
    chrome_options.add_argument('--ignore-certificate-errors')
    chrome_options.add_argument('--allow-running-insecure-content')
    chrome_options.add_argument("--disable-gpu")
    chrome_options.add_argument("--no-sandbox")
    driver = webdriver.Chrome(options=chrome_options)
    return driver

Here's the prompt I'm referring to:Certificate Prompt

Note: Some of the other answers found are exclusive to Windows. Would appreciate a Mac or "mixed" solution for the time being, thanks.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
Jona
  • 327
  • 4
  • 19

3 Answers3

0

I would suggest trying Following :

from selenium.webdriver.chrome.options import Options as ChromeOptions

    chrome_options = ChromeOptions()
    chrome_options.add_experimental_option(
        'prefs', {
            'required_client_certificate_for_user': <Path_to_certificate>
        }
    )

I got the prefs list from here https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/pref_names.cc following is the list of prefs which can be tried :-

"required_client_certificate_for_user" and "required_client_certificate_for_device"

Kumar Rishabh
  • 292
  • 1
  • 9
0

Selenium doesn't support certificate authentication natively, but you can use the Selenium WebDriver to download the certificate and then use the Selenium WebDriver to import the certificate into your browser.

DotNetRussell
  • 9,716
  • 10
  • 56
  • 111
  • Do you have sample code for it? If you're referring to the bottom solution that did not work for me at all. – Jona Dec 03 '22 at 03:48
0

I had the same problem in Java. You can cancel this confirmation pop-up directly in Selenium by adding the following argument to ChromeOptions: "--ignore-urlfetcher-cert-requests".

System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--ignore-urlfetcher-cert-requests");
driver = new ChromeDriver(options);

In Python, try to add :

chrome_options.add_argument('--ignore-urlfetcher-cert-requests')

In any case, it worked for me in Java!