0

I am currently using htmlunit to simulate scrapping of a web page that requires an ssl client certificate to be installed (https connection). This certificate has successfully been installed in my windows OS . On access of the given webpage via web browsers(chrome & IE), a prompt is issued to select a personal certificate that will be used . I would like to access the windows cert store preferably this personal certificate to authenticate and create a successful connection to my htmlunit client.

I have managed to research on the SunMSCAPI with Windows-MY to read the store as shown in below code.

        Provider provider = Security.getProvider("SunMSCAPI");
        KeyStore store = KeyStore.getInstance("Windows-MY", provider);
        store.load(null, null);

        Enumeration<?> aliases = store.aliases();
        while (aliases.hasMoreElements()) {
            String alias = aliases.nextElement().toString();
            if (alias.equals("mypersonalcert")) {

                Certificate[] signerKey = (Certificate[]) store
                        .getCertificateChain(alias);
                Object entry = store.getKey(alias, null);
                System.out
                        .println("cert aquired! got it");

            }
        }

How do I successfully integrate this to my htmlunit webconnection and web client instance for connection? Thanks in advance.

1 Answer 1

1

You could use WebClientOptions.setSSLClientCertificate(URL certificateUrl,String certificatePassword, String certificateType)

to point HTMLUnit to the client certificate of your choice.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.