James Lemieux
James Lemieux

Reputation: 750

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?

Upvotes: 2

Views: 2041

Answers (1)

MikeJRamsey56
MikeJRamsey56

Reputation: 2819

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) 

Upvotes: 3

Related Questions