title: Selenium Webdriver with Certificate Authentication in Python
body: <p>I am trying to automate the connection to a secure site that requires certificate authentication, in Python. This is from <strong>Windows</strong>, and does not have to be headless. My organisation does not play well with Firefox, so I have chosen to do this in <strong>Chrome</strong>. The certificate is a <strong>.pfx</strong></p>
  
  <p>I have come across older posts saying it cant be done at all with <strong>Chromedriver</strong> but a potential workaround would be to create a profile and import the certificate to that profile. When running the code, I reference the profile.</p>
  
  <p>My code so far:</p>
  
  <pre><code>from selenium import webdriver
  import time
  
  options = webdriver.ChromeOptions()
  options.add_argument('--ignore-certificate-errors')
  options.add_argument('user-data-
  dir=C:\\Users\\User\\AppData\\Local\\Google\\Chrome\\User Data\\')
  
  driver = webdriver.Chrome(executable_path='C:\\Users\\User\\WinPython-
  64bit-3.5.4.0Qt5\\python-
  3.5.4.amd64\\chromedriver.exe',chrome_options=options)
  time.sleep(3)
  driver.get('https://www.securesite.com')
  </code></pre>
  
  <p>This code results in a <strong>"This site can’t be reached"</strong> response. When trying it manually, a prompt will popup to choose confirm the certificate to use and I am able to proceed to the site successfully.</p>
  
  <p>When viewing <strong>certmgr.mmc</strong> I can see the certificate is imported under <strong>Personal</strong> as well as I have imported it to <strong>Trusted Root CA</strong>. From <strong>Chrome</strong> though when I view certificates, I find it <strong>only under Personal</strong>.</p>
  
  <p>I am not sure what I am doing wrong here, and I am hoping that during recent times - a solution has been found so someone would be able to advise me. </p>
  
  <p>Thank you</p>