Property Value
public string Thumbprint { get; }
Gets the thumbprint of the X.509 certificate. The thumbprint is a hash of the certificate's public key and other identifying information. It is commonly used to uniquely identify a certificate on a local computer.
Remarks
The thumbprint is generated using the SHA1 hash algorithm.
The thumbprint is represented as a hexadecimal string without any separators (e.g., "a90591a2c2f273d290b24e301f8749128835c509").
This property is read-only and can be accessed without needing to open the certificate in a store.
Examples
using System;
using System.Security.Cryptography.X509Certificates;
public class Example
{
public static void Main(string[] args)
{
// Load a certificate from the CurrentUser personal store
using (X509Store store = new X509Store("My", StoreLocation.CurrentUser))
{
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = (X509Certificate2Collection)store.Certificates;
if (certificates.Count > 0)
{
// Get the first certificate in the collection
X509Certificate2 cert = certificates[0];
// Get and display the thumbprint
string thumbprint = cert.Thumbprint;
Console.WriteLine($"Certificate Thumbprint: {thumbprint}");
}
else
{
Console.WriteLine("No certificates found in the CurrentUser personal store.");
}
}
}
}
Requirements
Namespace: System.Net.Security
Assembly: System.Net.Security.dll
| Exceptions |
|---|
| This property does not throw an exception. |