To validate in the client the certificate that it receives from the server, the validation method has a parameter of type X509Certificate that is the server certificate.
When I debug, I can see that it has a Thumbprint property, but when I try to access to them in the way myCertificate.Thmbprint I get a compiler error that it says that the property doesn't exist.
However, the type X509Certificate2 has this property.
So how could I get the thmbprint to know if it is the expected certificate?
Thanks.
It sounds like you're in a context where you have the cert as X509Certificate
rather than the more powerful X509Certificate2
.
Your two easy options:
X509Certificate2 myCertificate2 = (X509Certificate2)myCertificate;
)GetCertHash()
or GetCertHashString()
methods (depending on if you want bytes or the hex string). GetCertHashString()
is the same as the Thumbprint
property.