我想将公共(public)证书存储在数据库中,但我需要公共(public)证书的属性来索引数据库中的公共(public)证书。我想让它成为一个独特的领域。
公共(public)证书的指纹是唯一的吗?
最佳答案
指纹是唯一的(对于所有实际意图);两个不同的证书永远不应共享相同的哈希。例如,根据 Windows X509certificate2.thumbprint
documentation :
the thumbprint is a unique value for the certificate, it is commonly used to find a particular certificate in a certificate store.
根据 OpenSSL documentation :
Because of the nature of message digests the fingerprint of a certificate is unique to that certificate and two certificates with the same fingerprint can be considered to be the same.
请注意,指纹不是证书的一部分。相反,它是通过获取整个证书(包括签名)的加密哈希来计算的。 不同的加密实现可能使用不同的哈希算法来计算指纹,从而为同一个证书提供不同的指纹。 (例如,Windows Crypto API 计算证书的 SHA-1 哈希来计算指纹,而 OpenSSL 可以生成 SHA-256 或 SHA-1 哈希。)因此,您需要确保使用数据库指纹的客户端是使用相同的 API 或一致的哈希算法。
理论上,由多个证书共享的重复指纹将需要哈希冲突。这种偶然事件发生的概率是天文数字。有意生成这样的证书对需要对底层哈希函数进行成功的原像攻击,这种攻击在 SHA-1 上是不可行的(见 Preimage Attack)。
关于security - 公共(public)证书的指纹是唯一的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23986171/