I am developing a C++ application, and I need to check the thumbprint of a certificate.
I found this solution check for a specific signature, using CryptQueryObject(). but I still can't find a way to retrieve the Thumprint.
In C# I can use the method GetCertHashString to get the hash (which is what I need) or use the property X509Certificate.Thumbprint
I know I need to get the hash value of the public key, but I don't know how to retrieve the public key..
How do I do that in C++? is there a method for that?
Found how to do it.
you should use CryptHashCertificate
Like that:
DWORD* thumbPrintSize;
BYTE* thumbPrint;
if (!CryptHashCertificate(0, hashAlg, 0,pCertContext->pbCertEncoded,
pCertContext->cbCertEncoded, thumbPrint, thumbPrintSize)) {
return false;
}
Where pCertContext is the certificate, and hashAlg is the hashing algorithm (usually sha-1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With