C# : How can I retrieve the "personal" certificates installed on a remote computer

634 Views Asked by At

I want to fetch the expiry dates of all the "Personal" certificates installed on a Remote Computer. I have the computer's HostName. I am trying to retrieve the certificates using the code below:

X509Store store = new X509Store("personal", StoreLocation.LocalMachine);
foreach (X509Certificate2 c in store.Certificates)
{
    DisplayCertificate(c);
}
1

There are 1 best solutions below

0
On

Try to execute this using powershell in C#-

$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("\$server_name\My","LocalMachine")

$store.Open("ReadOnly")
$store.Certificates