Docker-selenium: Firefox webdriver gives "Insecure Connection" using HTTPS

Created on 19 Oct 2016  路  16Comments  路  Source: SeleniumHQ/docker-selenium

Meta - Images and versions

Docker-compose file:

...
selenium-hub:
  image: selenium/hub:3.0.0-dubnium
  ports:
    - "4444:4444"
  links:
    - superserver:mytargeturl.com

nodefirefox:
  image: selenium/node-firefox:3.0.0-dubnium
  ports:
    - 5900
  links:
    - selenium-hub:hub
    - superserver:mytargeturl.com

test:
  build: ./..
  dockerfile: dockerfiles/images/test
  links:
    - selenium-hub
    - nodefirefox
    - superserver:mytargeturl.com

Docker Version:

docker-compose version 1.8.0, build f3628c7

Testing:
I'm having a node container ("test") and several other node containers running. I have a container "superserver" which is a nginx instance allowing only https access. In my integration tests I'm using nightwatch to execute tests using selenium.

Expected Behavior

Example test:

  .url('https://mytargeturl.com')
  .waitForElementVisible('body', 5000)
  .getTitle((title) => {
    client.assert.equal(title, 'Expected title')
  })

If the site loads successfully it will be the expected title.

Actual Behavior

I'll get the page title "Insecure Connection".

This comment on SO pointed out that I require a HTTPS access but the webpage itself is actually served via HTTP and firefox gives a warning for security reasons.
I wanted firefox to ignore this alert, so I found this answer on SO which mentions the firefox option "accept_untrusted_certs". I've added this option to my nightwatch.json (test_settings.default.desiredCapabilitied.accept_untrusted_certs = true) - I tried camel case, too.
When I still got the "Insecure Connection" error I found out that it might be a problem of the firefox version (mentioned here).
To achieve an older firefox version (currently its firefox 49 in node-firefox:3.0.0-dubnium) I switched to node-firefox:2.50.0 which uses firefox 44.

Is there anything I did wrong and the solution is easier than mine or is this the right way to open a webpage via HTTPS which serves content via HTTP .

I know this might be a problem with firefox and not selenium or webdriver but this problem was so hard to solve and maybe someone else runs into the some problem.

Most helpful comment

See https://github.com/mozilla/geckodriver/issues/93 - if you need to run against sites with self-signed certificates then you may need to use the previous release until support for ignoring such security warnings lands in Marionette/GeckoDriver.

All 16 comments

+1
We are experiencing the same issue with the latest Selenium Docker image.

See https://github.com/mozilla/geckodriver/issues/93 - if you need to run against sites with self-signed certificates then you may need to use the previous release until support for ignoring such security warnings lands in Marionette/GeckoDriver.

@davehunt
Thank you for the reply.
Rolling back to 2.53.1-beryllium helped.

+1, have to be back on 2.53.1 because of self cert issue in firefox too :(

so it looks like Firefox 52 and 53 have this enabled? am i correct by what i read from that bugzilla issue, @davehunt ?

if so, you guys can build your own images with those versions, until we get the official images updated

@ddavison that's correct, from Firefox 52, users are able to set an additional capability to accept insecure certificates.

@sixinli @kaplich @Chaoste, the most recent image already has Firefox 53.

Could you please try again to use the additional capability and report back to see how it went?

confirmed that it works! thanks!

great news! closing

@sixinli @diemol, could you please share how to correctly set these capabilities in docker run command?

@joaoluizjoaquim no specific command to run to fix this.. it's just using the correct version. if you use latest, you're certainly covered. the commit was introduced in 3.4.0-bismuth. therefore,

versions >= 3.4.0-bismuth will work.

I still get "error": "insecure certificate", using 3.4.0-bismuth. Maybe I'm missing something else.

The log shows that the capability is set to false:
console 19:08:56.996 WARN - Exception thrown org.openqa.selenium.WebDriverException: Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: '95e9fdd875e1', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-62-generic', java.version: '1.8.0_121' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{moz:profile=/tmp/rust_mozprofile.SItEA04BF5q6, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=4.4.0-62-generic, moz:processID=86.0, browserName=firefox, javascriptEnabled=true, platformName=linux}]

try the latest image (dysprosium)

@ddavison , with the latest it seems to work. I've got another error message, but I think it's related to a geckodriver bug. After driver.quit() I get:

org.openqa.selenium.WebDriverException: Tried to run command without establishing a connection

Thank you anyway :+1:

I've got exactly the same problem with the recent version which was released 10 days ago. I will try dysprosium.

I've just tried earlier version:
REPOSITORY TAG CREATED SIZE
selenium/standalone-firefox-debug 3.4.0-dysprosium 4 weeks ago 685MB

Results from the Behat:
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: '84aaa2dfcb3c', ip: '172.18.0.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.31-moby', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=/tmp/rust_mozprofile.BjRAApBCv8HQ, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=4.9.31-moby, moz:processID=87.0, browserName=firefox, javascriptEnabled=true, platformName=linux}]

Is it possible to setup this option (acceptInsecureCerts=true) either in Behat or Docker file - ideally in docker-compose.yml?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Manolo2014 picture Manolo2014  路  3Comments

geekdave picture geekdave  路  4Comments

NeilJ247 picture NeilJ247  路  6Comments

alexellis picture alexellis  路  3Comments

testphreak picture testphreak  路  6Comments