Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChromeDriver opens sites only with valid SSL certs

There are two instances of the same site, only difference is, that one uses a valid, another one uses an invalid HTTPS/SSL certification. I tried to open both in headless ChromeDriver 2.31 and found it opens site only with valid SSL certification.

<chromepath> --headless --remote-debugging-port=9101 --disable-gpu <siteurl>

Code above opens a site https://chrome-devtools-frontend.appspot.com/serve_file/identification_number with a preview from the given website.

I use this to ignore certificate problems, but I get the same blank page for this site in ChromeDriver.

caps.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
like image 743
plaidshirt Avatar asked Sep 04 '17 11:09

plaidshirt


2 Answers

Late to the party, maybe it is useful to someone, the below parameter works for me.

acceptInsecureCerts: true
like image 108
Praveen Dharman Avatar answered Sep 21 '22 06:09

Praveen Dharman


you can use DesiredCapabilities

DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome ();       
handlSSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, false);
WebDriver driver = new ChromeDriver (handlSSLErr);

Try it, may be it helps you.

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 enter image description here

like image 27
iamsankalp89 Avatar answered Sep 21 '22 06:09

iamsankalp89