you can use DesiredCapabilities
DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome (); handlSSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, false); WebDriver driver = new ChromeDriver (handlSSLErr);
Try it, maybe it will help you.
The second way:
System.setProperty("webdriver.chrome.driver", "E:\\software and tools\\chromedriver_win32\\chromedriver.exe"); ChromeOptions option= new ChromeOptions(); option.addArguments("headless"); option.addArguments("ignore-certificate-errors"); WebDriver d=new ChromeDriver(option); //d.get("http://expired.badssl.com/"); d.get("https://expired.badssl.com/");
Image for reference 
iamsankalp89
source share