如何停止Chrome的Select证书window?

How to stop Chrome's Select a certificate window?

我正在做一个 Selenium 项目,我需要测试的系统正在使用 SSL 证书。每次我尝试登录时,我们都会收到这个“Select 证书”window,我们无法使用 WebDriver 处理。

我试过使用 AutoItx 单击“确定”按钮,如下所示。但是 Send("{ENTER}") 不是最好的选择。

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

有没有办法使用 AutoItX 来点击确定按钮?或者有没有一种方法可以在使用 Capabilities 定义 ChromeDriver 时加载此证书?

Chrome 版本 59.0.3071.86(64 位),Win 7 企业版:

创建注册表项:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\AutoSelectCertificateForUrls  

此处创建名称为 1

的新字符串值 (REG_SZ)

作为值数据输入:

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

This is how the registry then looks like.

有关此密钥的更多信息,我发现:

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.

Automatically select client certificates for these sites

Chrome 版本 87.0.4280.141(64 位),Win 10 企业版:

创建注册表项:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\AutoSelectCertificateForUrls  

此处创建名称为 1

的新字符串值 (REG_SZ)

作为值数据输入:

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

MyCompanyCA 和子域 mycompany.com 必须替换为相应的 url 和发行公司。

如果您有多个证书,而您想要 select 的证书不是第一个,那么您将需要应用过滤器。

http://www.chromium.org/administrators/policy-list-3#AutoSelectCertificateForUrls 对过滤器值进行了深入的描述,但您可能对其中的大多数都不感兴趣,可以使用:

{"pattern":"[*.]","filter":{"ISSUER":{"CN":"[Issued By]"}}}

[颁发者] 替换为您的客户端证书的颁发者。我一辈子都无法使 URL 模式与任何比 [*.] 更具体的模式一起工作,它匹配任何 URL.