证书颁发者的唯一标识符(X509Name)
在我的应用程序中,我使用颁发者名称的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从问题中尚不清楚您是否使用的是
java.security.cert.X509Certificate
,还是某些不使用 JCA 接口的 Bouncy Castle 类。无论如何,应该有一个方法返回代表颁发者 X.500 名称的对象。该对象应该有一个方法,以字节数组的形式返回名称的 ASN.1 编码。使用它作为密钥的组成部分。
如果您使用标准
X509Certificate< /code>
或 Bouncy Castle 的
X509CertificateObject
,使用类似的东西(如果您没有使用这些类之一,请更具体):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'sX509CertificateObject
, use something like this (and if you aren't using one of these classes, please be more specific):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).