I'm trying to use Java and Selenium to test a website that requires a client certificate. When I browse to my site I get a popup like the one below to select the correct certificate.
My requirements are as follows:
- Select a certificate by name
- On different versions of Windows / IE / Edge
Ideally the popup is never shown; i.e., the solution would involve invoking some API or setting some configuration to pin the correct certificate to use.
My own solution ideas:
I tried a solution based on visually detecting the correct certificate using SikuliX (which does works) but I'm wondering if there is a better solution that does not rely on visually detecting the popup. Something that is less likely to fail across multiple versions of Windows and that is future proof if Microsoft decides to change the appearance of this popup.
Another idea that I had (but I don't know how/if it is possible) is to remove all installed certificates except for one so that the popup is never shown:
- Backup the entire store
- Remove all client certificates that IE could use (except the one I need)
- Do the login which would no longer require any certificate selection
- Restore the backed up store
Does anyone know how to do this (in Java, possibly invoking CLI commands)?
Is it possible to start (using Selenium Java) an Internet Explorer Window that only knows the single certificate that I need?
Is it possible in Internet Explorer to set a default certificate for a given domain?
SSLContexts.custom().loadTrustMaterial(new File(PATH), PASSWORD, new TrustSelfSignedStrategy()).build();
? This will return a SSLContext. If it's a good way, I can help you on this, I worked on a SSL Self Signed certificate with Selenium. See : programcreek.com/java-api-examples/… (example 2) – Scalping