我正在开发 C++ 应用程序,我需要检查证书的指纹。
我找到了这个解决方案 check for a specific signature , 使用 CryptQueryObject()。但我仍然找不到检索指纹的方法。
在 C# 中,我可以使用方法 GetCertHashString获取哈希(这是我需要的)或使用属性 X509Certificate.Thumbprint
我知道我需要获取公钥的哈希值,但我不知道如何检索公钥..
我如何在 C++ 中做到这一点?有什么方法吗?
最佳答案
找到了如何去做。
你应该使用CryptHashCertificate
像那样:
DWORD* thumbPrintSize;
BYTE* thumbPrint;
if (!CryptHashCertificate(0, hashAlg, 0,pCertContext->pbCertEncoded,
pCertContext->cbCertEncoded, thumbPrint, thumbPrintSize)) {
return false;
}
其中pCertContext是证书,hashAlg是哈希算法(通常是sha-1)
关于c++ - 如何在 C++ 中检索证书指纹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13123777/