Chromedriver in Selenium and SSL Certificate

I use Selenium to test a website with HTTP Auth and now even an SSL certificate.

As a workaround for HTTP Basic Authentification I use ChromeDriver - http://code.google.com/p/selenium/wiki/ChromeDriver and opening URLs in the format

https://username:password@my-test-site.com

But now, for security reasons, a client certificate must be installed on a PC to enter this application.

However, ChromeDriver cannot see the “select certificate” prompt, and I cannot even switch to it as an alert.

Has anyone solved this problem?

+8
source share
3 answers

, , Chrome --ignore-certificate-errors.

ChromeDriver :

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
driver = new ChromeDriver(capabilities);
+5

Chrome URL-, KEY :

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\AutoSelectCertificateForUrls\1 = "{\"pattern\":\"https://www.example.com\",\"filter\":{\"ISSUER\":{\"CN\":\"cn of issuer\"}}}"

, .

Linux, , json, :

~/.config/chromium/Default/Preferences

, , Active Directory. , , , , , URL: https://www.chromium.org/administrators/policy-templates

+5

I solved this problem with the code below

DesiredCapabilities cap = DesiredCapabilities.chrome();
ImmutableMap<String, String> commandLineArguments = ImmutableMap.<String, 
String>builder()
    .put("web-security", "false")
    .put("ssl-protocol", "any")
    .put("ignore-ssl-errors", "true")
    .put("webdriver-loglevel", "DEBUG")
    .put("ssl-client-certificate-file", certificatePath)
    .put("ssl-client-key-passphrase", certificatePassword)
    .build();
String[] params = commandLineArguments.entrySet().stream()
    .map(e -> String.format("--%s=%s", e.getKey(), e.getValue()))
    .collect(Collectors.toList())
    .toArray(new String[0]);
cap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, params);
cap.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new PhantomJSDriver(cap);
driver.get(Url);

But I had to convert my pfx certificate to pem using the following command

openssl pkcs12 -in client_ssl_cert.pfx -out client_ssl_cert.pem -clcerts
+1
source

All Articles