关于证书签名过程的java问题
我对用 java 创建由 CA 签名的有效证书的过程感到困惑。
我知道java有工具keytool
来创建公钥-私钥和证书。
它还支持 JKS 和 PKCS#12。
因此,我们可以创建一个带有公钥-私钥对和证书的密钥库,例如
keytool -genkey -keyalg RSA -alias aCert -keystore someKeystore.keystore 这将创建一个带有证书(自签名)的密钥库。
到目前为止我明白了。
我可以导出 csr 请求的证书发送给 CA(例如 Verisign),当然不需要私钥。
在这部分之后我迷失了。
CA 将对其进行签名,我必须将其重新导入到我的密钥库中?这将替换密钥库中已有的原始证书?
但它仍然是自签名的。
颁发者不应该是 CA 本身吗?但这怎么可能?我只发送公钥而不发送证书?
请帮忙清理流程吗?
更新:
签署证书的 CA(例如 Verisign)也是颁发者吗?或者它可以签署颁发者==主题
的证书?
谢谢
I am confused on the process to create a valid certificate,signed by a CA, in java.
I know that java has the tool keytool
to create public-private keys and certificates.
Also it supports JKS and PKCS#12.
So one can create a keystore with a public-private key pair and a certificate e.g.keytool -genkey -keyalg RSA -alias aCert -keystore someKeystore.keystore
This will create a keystore with a certificate (self-signed).
So far I understand.
I can export the certificate for a csr request to send to a CA e.g. Verisign, without the private key of course.
After this part I am lost.
The CA will sign it and I will have to re-import it to my keystore?This will replace the original certificate already in keystore?
It will still be self-signed though.
Shouldn't the issuer be the CA itself?But then how is this possible?I just send the public key only and not a certificate?
Any help on clearing the process please?
UPDATE:
Is the CA signing the certificate (e.g. Verisign) also the issuer?Or it can sign a certificate that the issuer==subject
?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在创建 CSR 方面,您是正确的。您将使用类似以下内容:
生成 CSR,其中包含:
,并由您的签名者签名私钥。然后,CA 生成一个新证书,其中包含:
,您需要将其导入回您的证书密钥库,替换原始自签名证书:
CA 通常会使用中间证书签署您的新证书,而该中间证书又由可信根签名;在这种情况下,您应该在自己的证书之前导入中间证书:
编辑: keytool 文档中的这个模糊部分非常清晰(其中谈到证书“链”,这仅指中间证书将您的链接链接到根):
You're correct up to the point of CSR creation. You'll use something like this:
to generate a CSR, which contains:
and is signed with your private key. The CA then generates a new certificate with:
which you need to import back into your keystore, replacing the original self-signed cert:
Often CAs will sign your new certificate using an intermediate certificate which is in turn signed by a trusted root; in this case you should import the intermediate certificate before your own:
Edit: this obscure section from keytool's documentation is surprisingly clear (where it talks about a 'chain' of certificates, this just refers to the intermediate certificates that link yours to the root):
CA 签署证书后,它就不再是自签名的。自签名证书的颁发者==主题。当 CA 对其进行签名时,颁发者就成为 CA,它对应于 CA 自己的证书中的主题,而该证书又由另一个颁发者签名,...因此您拥有一个证书链,该证书链终止于已受信任的根中在您的信任库中。
After the CA signs the cert it ceases to be self-signed. A self-signed certificate has issuer == subject. When the CA signs it, issuer becomes the CA, which corresponds to the subject in the CA's own certificate, which in turn is signed by another issuer, ... so you have a certificate chain, that terminates in a trusted root that is already in your truststore.