java p12证书转jsk,将一个证书存储到我的Java密钥库中后出现多个条目

I'm using the class InstallCert to import a VMware vCenter certificate into my local Java keystore.

The line socket.startHandshake() returns an UnsupportedOperationException, but the class SavingTrustManager still has downloaded the certificate successfully.

Then I store the downloaded certificate into my local keystore by using the following snippet.

KeyStore jsk;

... ... ..

jks.setCertificateEntry(alias, cert);

OutputStream out = new FileOutputStream("jssecacert");

jks.store(out, passphrase);

out.close();

But when I try to list all the entries in the keystore: keytool -list -keystore jssecacerts -v, It shows that there are 160 entries including the one that I have downloaded.

I'm pretty sure that the keystore is generated by my code, and it is supposed to be initially empty. I'd like to know where do the other 159 entries come from ?

Thanks.

解决方案

Use KeyStoreExplorer for comparing both truststores: jssecacerts generated by the Installcert class, and the cacerts file located en your Java>jre>security>lib.

Istallcert takes the certificate from the server and creates a copy of the truststore of the JVM you are using. then it adds the certificate to the copy of your truststore, and names it "jssecacerts". Check this piece of code:

File file = new File("jssecacerts");

if (file.isFile() == false) {

char SEP = File.separatorChar;

File dir = new File(System.getProperty("java.home") + SEP

+ "lib" + SEP + "security");

file = new File(dir, "jssecacerts");

if (file.isFile() == false) {

file = new File(dir, "cacerts");

}

}

You then just need to rename jsscacerts to cacerts and replace the original one on your JVM

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值