如何使用java获取客户端证书列表?

时间:2014-07-01 12:14:40

标签: java x509

我有下一个代码:

        // Load the JDK's cacerts keystore file
        String filename = System.getProperty("java.home") + "/lib/security/cacerts".replace('/', File.separatorChar);
        FileInputStream is = new FileInputStream(filename);
        KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
        String password = "changeit";
        keystore.load(is, password.toCharArray());

        // This class retrieves the most-trusted CAs from the keystore
        PKIXParameters params = new PKIXParameters(keystore);

        // Get the set of trust anchors, which contain the most-trusted CA certificates
        Iterator it = params.getTrustAnchors().iterator();
        while( it.hasNext() ) {
            TrustAnchor ta = (TrustAnchor)it.next();
            // Get certificate
            X509Certificate cert = ta.getTrustedCert();
            System.out.println(cert);
        }

有了这个我有信任根证书列表,但我想要客户端认证列表,你可以在Internet Explorer中找到的认证。

有人可以帮助我吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/jcp/jcp.html#security,您可以看到证书存储在${user.home}/.java/deployment/security

所有浏览器都在其特定位置管理证书。