How does Selenium Webdriver handle SSL certificate in Chrome?

We can handle SSL certificate with Selenium webdriver in Chrome browser. A SSL is the standardized protocol used to create a connection between the browser and server.

The information exchanged via a SSL certificate is encrypted and it verifies if the information is sent to the correct server. It authenticates a website and provides protection from hacking.

An untrusted SSL certificate error is thrown if there are problems in the SSL certificate. We shall receive such an error while we launch a website. In Chrome, we use the ChromeOptions class to work with SSL certificates.

We shall create an instance of this class and set the capability - setAcceptInsecureCerts to true. Finally, this property of the Chrome browser shall be passed to the webdriver object.


ChromeOptions c = new ChromeOptions();


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class SSLErrorChrome {
   public static void main(String[] args) throws IOException {
      //object of ChromeOptions
      ChromeOptions c = new ChromeOptions();

      //set browser properties
      // pass browser option to webdriver
      WebDriver driver = new ChromeDriver(c);
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("application url to be entered");