2

I am creating a testcase to test a secure website with Capybara and selenium webdriver.

webapp i want to test is secured https type, so i need to pass my ssl certificate(client side certificates) information to webserver to accept my connection. I know i can pass .pem certificates to https connection when i request through a Rest client.

    cert = File.read('pem_file_location')
    http.use_ssl = true
    http.cert = OpenSSL::X509::Certificate.new(cert)
    http.key = OpenSSL::PKey::RSA.new(cert)
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE

I am looking for similar approach if i want to make https connection through firefox driver.

I got one solution where i create custom firfox profile and incorporate certificate into that profile and use it when i run tests. But i dont want this solution as profiles are not allowed on CI servers in my company.

Any help would be appreciated

maddy
  • 41
  • 1
  • 5

1 Answers1

1

Well, if you are running Selenium Grid (as described here) , you can give the Node configuration for Firefox the "acceptSslCerts=true" option and, in theory, it will accept the cert probably as long as the cert is from one of the trusted cacerts authorities that come included with the browser.

Now, this wont work if you created your own custom CA authority, unless you first manually import the CA into the browser cacerts store.

djangofan
  • 28,471
  • 61
  • 196
  • 289
  • 1
    djangofan, Thank you for reply.No i am not using grid.Out application functionality is quite simple not required for grid. Yeah i want to use custom CA cert.But problem is we dont have access on CI to customise firefox profile.I was looking for some thing i can dynamically create profile and pass cert details into that. – maddy Jun 25 '13 at 11:31
  • 1
    you can check-in a .zip archive of a prebuilt Firefox profile (with your cert CA pre-imported) into your revision control and when your CI checks out the code, it will have it. is that an option for you? – djangofan Jun 25 '13 at 15:54
  • 1
    Thanks again,It is an option i tried on my devlopment machine it worked.But as per company policy certificates not allowed to store in revision control.I can have my certificates on CI server at certain location and i want to pass this information to Firefox driver through some configuration commands with capybara.That would have neat solution.Similar to net/http gem we use for REST requests.And also my own custom profiles on CI servers is not an option as per compnay norm. – maddy Jun 28 '13 at 15:07
  • 1
    Seems like you could dynamically build the profile without having to store it on the server by downloading the CA from another site. Then use certutil to import it? http://stackoverflow.com/questions/1435000/programmatically-install-certificate-into-mozilla – djangofan Jun 28 '13 at 16:34