证书颁发者的唯一标识符(X509Name)

发布于 2024-11-25 20:17:08 字数 238 浏览 4 评论 0原文

在我的应用程序中,我使用颁发者名称的 sha256 (x509CertImpl.getIssuerDN().getName()) 和证书序列号来唯一标识证书,但现在我已经意识到 X509Name 的其他实现作为 Bouncy 的实现当我调用 bcX509Name.getName() 时,Castle 库显示不同的内容,因此该标识符对我不起作用...我的问题是如何获得一个唯一标识符X509Name...也许两者的 ASN.1 或 DER 编码表示形式是相同的。

in my app I'm using the sha256 of the issuer Name (x509CertImpl.getIssuerDN().getName()) and the certificate serial number to uniquely identify a certificate, but now I have realized that other implementations of X509Name as the implementation of Bouncy Castle library displays something different when I call bcX509Name.getName() so this identifier doesn't work for me... my question is how could I get an unique identifier for an X509Name... maybe an ASN.1 or DER encoded representation of both will be the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏日浅笑〃 2024-12-02 20:17:08

从问题中尚不清楚您是否使用的是 java.security.cert.X509Certificate,还是某些不使用 JCA 接口的 Bouncy Castle 类。

无论如何,应该有一个方法返回代表颁发者 X.500 名称的对象。该对象应该有一个方法,以字节数组的形式返回名称的 ASN.1 编码。使用它作为密钥的组成部分。

如果您使用标准 X509Certificate< /code>或 Bouncy Castle 的 X509CertificateObject,使用类似的东西(如果您没有使用这些类之一,请更具体):

X509Certificate x = ...;
byte[] issuer = x.getIssuerX500Principal().getEncoded();

It is not clear from the question whether you are using a java.security.cert.X509Certificate, or some Bouncy Castle class that doesn't use the JCA interfaces.

In any case, there should be a method that returns an object that represents the issuer's X.500 name. This object should have a method that returns the ASN.1 encoding of the name as a byte array. Use this as a component of your key.

If you are using the standard X509Certificate or Bouncy Castle's X509CertificateObject, use something like this (and if you aren't using one of these classes, please be more specific):

X509Certificate x = ...;
byte[] issuer = x.getIssuerX500Principal().getEncoded();
故事与诗 2024-12-02 20:17:08

IssuerDN 是一个复杂的结构,不同的库可能有不同的将其“序列化”为字符串的机制。因此,您可能需要重新考虑您的方法。一般来说,使用证书本身的哈希值(整体)+序列号比较(使冲突的可能性几乎为0)就可以了。

IssuerDN is a complex structure and different libraries might have different mechanisms of "serializing" it to string. So you might need to re-think your approach. In general it's ok to use hash of the certificate itself (in whole) + serial number comparison (to bring possibility of collision to almost 0).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文