简体   繁体   English

使用Java2se HTML单元的SSL客户端证书认证

[英]SSL client certificate authentication with Java2se html-unit

I am currently using htmlunit to simulate scrapping of a web page that requires an ssl client certificate to be installed (https connection). 我目前正在使用htmlunit模拟需要安装ssl客户端证书(https连接)的网页的抓取。 This certificate has successfully been installed in my windows OS . 该证书已成功安装在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 . 通过网页浏览器(chrome和IE)访问给定网页时,会提示您选择要使用的个人证书。 I would like to access the windows cert store preferably this personal certificate to authenticate and create a successful connection to my htmlunit client. 我想访问Windows证书存储,最好是此个人证书,以进行身份​​验证并建立与我的htmlunit客户端的成功连接。

I have managed to research on the SunMSCAPI with Windows-MY to read the store as shown in below code. 我设法对Windows-MY的SunMSCAPI进行了研究,以读取存储,如下面的代码所示。

        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? 如何将其成功集成到htmlunit webconnection和Web客户端实例进行连接? Thanks in advance. 提前致谢。

You could use WebClientOptions.setSSLClientCertificate(URL certificateUrl,String certificatePassword, String certificateType) 您可以使用WebClientOptions.setSSLClientCertificate(URL certificateUrl,String certificatePassword,String certificateType)

to point HTMLUnit to the client certificate of your choice. 将HTMLUnit指向您选择的客户端证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 蓝牙低功耗发现JAVA2SE - Bluetooth Low Energy Discovery JAVA2SE 带有SSL身份验证的Java SOAP客户端:错误证书 - Java SOAP Client with SSL authentication : bad certificate SSL 错误:在 java 中没有找到合适的证书而无需客户端身份验证继续 - SSL Error : no suitable certificate found continuing without client authentication in java Java - 使用客户端证书身份验证时取消Ssl流 - Java - Ssl stream is cancelled when using client certificate authentication 在 Java 中选择 SSL 客户端证书 - Choosing SSL client certificate in Java 具有SSL客户端身份验证的Java RMI:获取客户端x509证书 - Java RMI with SSL client authentication: obtain client x509Certificate 使用运行时Android / Java上提供的客户端证书进行TLS / SSL客户端身份验证 - TLS/SSL client authentication using a client certificate which comes available at runtime Android/Java Java 6 HTTPS客户端证书认证 - Java 6 HTTPS client certificate authentication 在没有证书的SSL握手中添加客户端身份验证 - Adding client authentication in SSL handshake without certificate 如何在Java SE中使用SSL设置相互身份验证 - How to set mutual authentication using SSL in Java SE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM