Invalid certificate error with Geckodriver on FF 51

て烟熏妆下的殇ゞ 提交于 2019-12-12 02:23:22

问题


I am using Selenium 3 on Firefox 51.0.1 with Geckodriver release v0.14.0. I am getting an error on the browser trying to open the URL, and it says the connection is not secure (certificate error), although I checked the certificate and it is valid.

The error is this:

Command failed: open target="" value="https://mydomain.mysite.com/default" -> Reached error page: about:certerror?e=nssBadCert&u=https%3A//mydomain.mysite.com/default&c=UTF-8&f=regular&d=mydomain.mysite.com%20uses%20an%20invalid%20security%20certificate.%0A%0AThe%20certificate%20is%20not%20trusted%20because%20the%20issuer%20certificate%20is%20unknown.%0AThe%20server%20might%20not%20be%20sending%20the%20appropriate%20intermediate%20certificates.%0AAn%20additional%20root%20certificate%20may%20need%20to%20be%20imported.%0A%0AError%20code%3A%20%3Ca%20id%3D%22errorCode%22%20title%3D%22SEC_ERROR_UNKNOWN_ISSUER%22%3ESEC_ERROR_UNKNOWN_ISSUER%3C/a%3E%0A

I am using the following code (partial snippet below) to set the capabilities on FF, and it appears that acceptSslCerts​ is not getting set to true.

System.setProperty("webdriver.gecko.driver", geckoDriverLocation);

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, 1);

FirefoxProfile profile = new FirefoxProfile();

// Set the download path in Firefox profile
profile.setPreference("browser.download.dir", "/User/me/download");
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting",false);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "images/jpeg, application/pdf, application/octet-stream, application/zip, application/xml");
profile.setPreference("pdfjs.disabled", true);​

profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);

desiredCapabilities.setCapability(FirefoxDriver.PROFILE, profile);
desiredCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
desiredCapabilities.setCapability("acceptInsecureCerts", true);

return new FirefoxDriver(desiredCapabilities);

If I put a breakpoint on the last statement above and check, it returns ((RemoteWebDriver) webDriver).getCapabilities().getCapability("acceptSslCerts") as false. That is acceptSslCerts is not getting set to true. The detailed error message (not shown here) shows the same fact.

Could this be the reason why the error is happening? What could be done to ensure this value (acceptSslCerts) gets set correctly?

Note that the error does not occur with Selenium 2 on FF 47 with Firefoxdriver.

Any help will be greatly appreciated.


回答1:


As per the update posted below, it is not possible to fix the above problem unless Firefox v52 is used.

https://www.hskupin.info/2017/01/23/using-selenium-and-webdriver-to-interact-with-insecure-ssl-pages-in-firefox/

Tried out with FF 52 which is still in beta. It worked!



来源:https://stackoverflow.com/questions/42285149/invalid-certificate-error-with-geckodriver-on-ff-51

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!