views:

780

answers:

4

Hi all,

I am testing my web application's security and all of my pages are served over ssl. The issue I am having is the certificate is not trusted as firefox starts in a new profile each time. I was reading on OpenQA's site about a jar and importing the certificate, but that is only for Internet Explorer and Firefox should automatically be handled.

Is there anything special I need to do in order for certificates to automatically be trusted?

Thanks, Walter

+3  A: 

Create a new blank Firefox profile, accept the cert, and then use that as your profile.

Instructions here: http://townx.org/blog/elliot/dealing-self-signed-ssl-certificates-when-running-selenium-server-firefox

I realize you are using Maven, but in Ant you would:

<target name="selenium" description="Runs the QA Selenium HTML test suite">
  <mkdir dir="build/reports/selenium"/>
  <java jar="${selenium.dir}/selenium-server.jar" fork="true" spawn="false">
    <arg value="-htmlSuite"/>
    <arg value="*chrome"/>
    <arg value="${selenium.browser.url}"/>
    <arg value="selenium-test/testSuite.html"/>
    <arg value="build/reports/selenium"/>
    <arg value="-firefoxProfileTemplate"/>
    <arg value="selenium-test/sslSupport"/>
    <arg value="-trustAllSSLCertificates"/>
    <arg value="-timeout"/>
    <arg value="300000"/>
  </java>
</target>

I put the Firefox profile under selenium-test/sslSupport, selenium.dir is where selenium is installed, and selenium.browser.url is the URL to start the test at.

CoverosGene
This works for ant - I am still having issues specifying which profile I want the tests to use. If I specify one with the -P flag, selenium fails to get a session.
+1  A: 

You can install the RCE (Remember Certificate Exception) Firefox add-on To a custom firefox profile, which will then accept all unknown certificates when they are encountered. You will need to modify any waitForPageToLoad commands though so that they allow for the certificate to be accepted. In my setup (Java/TestNG/Selenium RC) I have a waitForUnsecuredPageToLoad method that checks to see if the title of the loaded page is the certificate warning page, and if so I waitForPageToLoad again. It works well and is cross browser safe.

Dave Hunt
How do you specify what profile Firefox uses in selenium? I tried modifying the startup command; however, that didn't seem to do the trick (selenium would be unable to get a session). If I could specify which profile it's going to use, then I could just accept the certificate since it is local in my testing environment.
Use the Selenium RC command line parameter -customFirefoxProfile
Dave Hunt
Dave, thanks, but I've tried that and every time I try, firefox never starts. I tried specifying the full path to the executable I want to run as well as the custom selenium profile which already has the certificates I want it to accept, accepted and installed.
A: 

I am using HtmlUnit instead and while it does not really test browser compatibility, it does help ensure stuff works.

Walter

A: 

This can be done by starting up the Selenium server with the '-trustAllSSLCertificates' and configuring the browser to use the Selenium server as a proxy. Depending on how you set up Firefox, you can either use a custom profile to set up the proxy settings or use a custom browser launcher that can set that up for you.

I wrote up an article that goes into more details with some code samples:

http://mogotest.com/blog/2010/04/13/how-to-accept-self-signed-ssl-certificates-in-selenium

Hopefully that helps you out.

nirvdrum