使用 Java 和 Bouncycastle 验证 X.509 证书
通过 bouncycastle wiki 页面 我能够理解如何创建 X.509 根证书和认证请求,但我不太明白如何在此之后进行概念和编程。
假设 A 方发出证书请求并从 CA 获取其客户端证书。 B 方如何验证 A 的证书? A需要什么样的证书?根证书? “普通”客户端证书?
如果我们假设 A 已成功将其 DER 或 PEM 格式的证书发送给 B,那么编程级别的验证如何进行?
非常感谢任何帮助。
此致, 抢
through the bouncycastle wiki page I was able to understand how to create a X.509 root certificate and a certification request, but I do not quite understand how to proceed concept- and programming wise after that.
Lets assume party A does a cert request and gets his client certificate from the CA. How can some party B validate A's certificate? What kind of certificate does A need? A root certificate? A 'normal' client certificate?
And how does the validation work on programming level, if we assume that A has successfully send his certificate in DER or PEM format to B?
Any help is much appreciated.
Best Regards,
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从程序员的角度来看,您需要一些东西来验证 X.509 证书。
有了这些可用的输入,您就可以使用 内置 -在 PKIX 支持中构建和验证证书路径。
需要注意的重要一点是,如果找不到路径,您将无法获得有关原因的太多信息。这可能会令人沮丧,但设计就是如此。一般来说,有很多潜在的路径。如果它们都因不同原因失败,路径构建器将如何决定报告什么原因?
From a programmer's perspective, you need a few things to validate an X.509 certificate.
With these inputs available, you can use the built-in PKIX support to construct and validate a certificate path.
An important thing to note is that if a path cannot be found, you don't get much information about the reason. This can be frustrating, but it is that way by design. In general, there are many potential paths. If they all fail for different reasons, how would the path builder decide what to report as the reason?
好的,CA 背后的想法如下:
在编程层面上,您可以通过读取 X.509 证书并确定 CA 应该是谁来实现这一点。有了该 CA 的指纹,您可以在数据库中找到它并验证签名。如果匹配,则您拥有信任链。
这是有效的,因为正如我所说,只有 CA 可以创建数字签名,但任何人都可以验证它。这与加密概念正好相反。您要做的就是“用私钥加密”您想要签名的数据,并验证“用公钥解密”是否等于您获得的数据。
Ok, the idea behind CAs is as follows:
On a programmatic level, you implement this by reading the X.509 certificate and working out who the CA is supposed to be. Given that CA's fingerprint, you find it in your database and verify the signature. If it matches, you have your chain of trust.
This works because, as I've said, only the CA can create the digital signature but anyone can verify it. It is exactly the reverse of the encryption concept. What you do is "encrypt with the private key" the data you wish to sign and verify that the "decrypt with the public key" equals the data you've got.