Python Selenium - How to specify a client certificate to use in client SSL authentication Python Selenium - How to specify a client certificate to use in client SSL authentication selenium selenium

Python Selenium - How to specify a client certificate to use in client SSL authentication


As I can see in the source code, you could create a firefox profile with a parameter (profile_directory) and get firefox launched with the given profile. I think you may also set the preference profile.accept_untrusted_certs = True.

The given profile directory should have client certificates prepared.

# Prepared Firefox profile directoryprofile = FirefoxProfile(profile_diretory)profile.set_preference("security.default_personal_cert", "Select Automatically")profile.set_preference("webdriver_accept_untrusted_certs", True)self.driver = WebDriver(firefox_profile=profile)


To piggyback on the previous response here's what I did.

In my python code: I have:

import osprofile_directory = os.path.join(os.path.abspath(os.sep),"home","rumpelstiltskin","my_cert_db")self.driver = WebDriver(firefox_profile=profile)

Then to create the cert8.db file I used the following terminal commands:

cd /home/rumpelstiltskinmkdir my_cert_dbcertutil -N -d sql:my_cert_db/pk12util -n my-cert-name -d sql:my_cert_db/ -i /my/path/to/cert.p12