Saving certificate chain in a pkcs12 keystore(将证书链保存在 pkcs12 密钥库中)
问题描述
The following code:
where certChain holds the end certificate and the issuer certificate (i.e. two certificates),
doesn't save the issuer certificate as part of the chain in the saved to the file system keystore file if the keyStore is an instance of PKCS12
.
It does save both certificates if the keystore type is PKCS12-3DES-3DES
.
Why is this? Doesn't a PKCS12 suppose to have both certificates are part of the chain?
EDIT: Here's an SSCCE. This works fine with "JKS"
, fails with "PKCS12"
: Only the first certificate in the chain is accessible via getCertificateChain(String)
. The saved file can be opened with openssl pkcs12
revealing both certificates.
Your code has 2 error:
first: You not set Issuer for certificate (client cert should be issued by CA to make valid chain).
second: You use wrong order when create certificate chain (should be client certs, CA last)
here is reworked SSCCE, and it works without errors.
这篇关于将证书链保存在 pkcs12 密钥库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!