How to stop chrome's Select a certificate window

十年热恋 提交于 2019-12-22 12:57:21

问题


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

I have tried click on ok button using AutoItx as below. But the Send("{ENTER}") is not the best option continue with.

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

Is there a way to use and click on OK button using autoItx. Or is there a way we can load this certificate when defining chromedriver by using Capabilities.

Appreciate any ideas to solve this issue.


回答1:


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

Create registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\AutoSelectCertificateForUrls

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




回答2:


If you have multiple certificates and the one you want to select is not the first one then you will need to apply a filter.

http://www.chromium.org/administrators/policy-list-3#AutoSelectCertificateForUrls has an in-depth description of the filter values, but you're probably not interested in most of them and can use:

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

replacing [Issued By] with the issuer of your client certificate. I can't for the life of me manage to get the URL pattern working with anything more specific than [*.], which matches any URL.



来源:https://stackoverflow.com/questions/40653785/how-to-stop-chromes-select-a-certificate-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!