Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

ssl - How to stop Chrome's Select a certificate window?

I'm working on a Selenium project and the system I need to test is using an SSL certificate. Every time when I try to login we are getting this "Select a certificate" window which we cannot handle with WebDriver.

Chrome select a certificate window

I have tried clicking OK button using AutoItx as below. But the Send("{ENTER}") is not the best option.

if (AutoItX.WinWaitActive("data:, - Google Chrome", "", 10) == 0)
{
   AutoItX.WinActivate("data:, - Google Chrome");
   AutoItX.Send("{ENTER}");
}

Is there a way to click on OK button using AutoItX? Or is there a way we can load this certificate when defining ChromeDriver by using Capabilities?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Chrome Version 59.0.3071.86 (64-Bit), Win 7 Enterprise:

Create registry key:

HKEY_LOCAL_MACHINESOFTWAREPoliciesGoogleChromeAutoSelectCertificateForUrls  

Here create new String value (REG_SZ) with name 1

As Value data enter:

{"pattern":"[*.]","filter":{}}

This is how the registry then looks like.

For more information on this key I found:

The value must be an array of stringified JSON dictionaries. Each dictionary must have the form { "pattern": "$URL_PATTERN", "filter" : $FILTER }, where $URL_PATTERN is a content setting pattern. $FILTER restricts from which client certificates the browser will automatically select. Independent of the filter, only certificates will be selected that match the server's certificate request. If $FILTER has the form { "ISSUER": { "CN": "$ISSUER_CN" } }, additionally only client certificates are selected that are issued by a certificate with the CommonName $ISSUER_CN. If $FILTER is the empty dictionary {}, the selection of client certificates is not additionally restricted.

on Automatically select client certificates for these sites

Chrome Version 87.0.4280.141 (64-Bit), Win 10 Enterprise:

Create registry key:

HKEY_LOCAL_MACHINESOFTWAREPoliciesGoogleChromeAutoSelectCertificateForUrls  

Here create new String value (REG_SZ) with name 1

As Value data enter:

{"pattern":"[*.]mycompany.com","filter":{"ISSUER":{"CN":"MyCompanyCA"}}}

enter image description here

MyCompanyCA and the subdomain mycompany.com must be replaced with your corresponding url and issuing company.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...