plaidshirt plaidshirt - 2 months ago 40
Java Question

WebDriver to disable SEC_ERROR_UNKNOWN_ISSUER in Firefox

WebDriver
opens browser window, but I get
SEC_ERROR_UNKNOWN_ISSUER
.
I tried to add this site as an exception in browser, but when new browser window opened I get the same message again instead of the website.

FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
options.setLogLevel(Level.ALL);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options);
WebDriver driver = new FirefoxDriver(capabilities);

Answer Source

You need to set setAcceptInsecureCerts Capabilities as true

This simple code work for me :-

 System.setProperty("webdriver.gecko.driver", "D:\\Workspace\\StackOverlow\\src\\lib\\geckodriver.exe");
 DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
 desiredCapabilities.setAcceptInsecureCerts(true);
 WebDriver driver = new FirefoxDriver(desiredCapabilities);
 driver.get("https://self-signed.badssl.com/");

OR

     System.setProperty("webdriver.gecko.driver", "D:\\Workspace\\StackOverlow\\src\\lib\\geckodriver.exe");
     DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
     desiredCapabilities.setCapability("acceptInsecureCerts", true);
     WebDriver driver = new FirefoxDriver(desiredCapabilities);
     driver.get("https://self-signed.badssl.com/")

Change your gecko path in first line of code. Update gecko driver and firefox

enter image description here