Search code examples
pythonseleniumsslselenium-webdriverbrowsermob-proxy

Adding SSL certificate to Selenium


I am working with BrowserMob-Proxy and Selenium. Loading pretty much any URL results in a Your connection is not secure, Error code:SEC_ERROR_UNKNOWN_ISSUER error in the browser. However, when I import the certificate given by BMP (via Firefox->Options->Advanced->Certificates->Import), everything works smoothly.

My question is how to do this programmatically. I have already tried

profile.accept_untrusted_certs = True

but that doesn't seem to have any affect at all. Any way to to this?


Solution

  • Create a new firefox profile "sslProfile". See firefox help for your OS.

    In your selenium code:

    ProfilesIni prof = new ProfilesIni()                
    FirefoxProfile foxProfile= prof.getProfile ("sslProfile")
    
    foxProfile.setAcceptUntrustedCertificates(true) 
    foxProfile.setAssumeUntrustedCertificateIssuer(false)
    
    WebDriver driver = new FirefoxDriver (foxProfile)