【发布时间】:2017-10-16 16:03:19
【问题描述】:
我创建了一个证书存储,并想从该类的另一个函数中添加另一个证书。
使用caCert 和intermediateCert 在类 1 中创建链:
List<X509Certificate> certList = new ArrayList<X509Certificate>();
certList.add(0, interCert);
certList.add(1, caCert);
Store<X509Certificate> certs = new JcaCertStore(certList);
certStore = new JcaCertStoreBuilder().addCertificates(certs).build();
我想在类 2 中添加一个新的构建用户证书:
certStore = new JcaCertStoreBuilder().addCertificate(certHolder).build();
要将新密钥保存到我的KeyStore,我需要一个证书数组(X509Certificate[])。如何将 certStore 文件转换为数组以使 privatekeyentry 工作?
PrivateKeyEntry privKeyEntry = new PrivateKeyEntry(pair.getPrivate(), chain);
store.setEntry(alias, privKeyEntry, new KeyStore.PasswordProtection(storePassword));
【问题讨论】:
-
你在使用 bouncycastle 吗?
-
是的,我确实使用 bouncycastle。
标签: java arrays certificate bouncycastle keystore