Selenium Auto Accept Self Signed SSL Certificates and Basic Authentication

Selenium Auto Accept Self Signed SSL Certificates and Basic Authentication
March 19 11:00 2011 Print This Article

One of my biggest annoyances and unresolved issues with Selenium is the self-signed SSL certificates. This was a huge issue for me on the last project when we had dozen test runners and the same amount of servers behind load balancers all with invalid SSL certificates. The terrible solution at the time was to add the certificate to my Firefox profile and keep updating it every other day.

Good news! Selenium server has some cool things built into it, that will make your life much easier. First, always Accept SSL certificates; Second, allow basic authentication to be automatically passed down to every page you try to access.

I have to thank this kind person for posting this info:


Let’s get started

1) Use selenium server as a proxy
This is a major one, once you configure your browser to use the RC server as a proxy you get a lot of things for free. The easiest way to accomplish this step on firefox is to create a custom firefox profile that you will use to test (See custom selenium profiles) and add the HTTP and SSL proxy to be pointing to “localhost” port “4444″.

Note: Make sure you are not using “-avoidProxy” flag when you are launching the selenium server

2) Enable acceptance of all Self Signed SSL certificates

Use ”

-trustAllSSLCertificates” flag in your Selenium server launcher.

3) Trust the CiberVillan certificate

cybervillainsCA.cer comes packaged with selenium server, look under sslSupport folder. You will need to install this certificate in your browsers.

For Firefox, just drag this certificate into the opened browser while it is running in your selenium testing profile

For IE, you will have to follow the CiberVillan certificate installation on the system.

4) Enable automatic basic authentication

To have basic authentication, we just need to add your username and password to all of the request headers. In ruby this is done with this code snippet:

@browser = \
:host => "localhost",
:port => 4444,
:browser => "*firefox",
:url => "http://localhost:4444",
:timeout_in_second => 20

encoded = Base64.encode64("USERNAME:PASSWORD").strip
@browser.remote_control_command('addCustomRequestHeader', ['Authorization', "Basic #{encoded}"])

Note: Make sure your initial URL is pointing to localhost, you do not want to hit your domain yet because we have not added the authentication header until the last 2 lines

5) Start running your test

All you have to do now is tell the browser to hit your site


Related Posts:

About Article Author

view more articles
Nataliia Vasylyna
Nataliia Vasylyna

View More Articles

1 Comment

write a comment
  1. john stanley
    February 25, 08:43 #1 john stanley

    u had given a very good information about selenium self signed and basic authentication it is very good.

    Reply to this comment

Add a Comment

Your data will be safe! Your e-mail address will not be published. Also other data will not be shared with third person.
All fields are required.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.