Print all certificates of a chain in PowerShell

PowerShell

Here is a code that demonstrates how to get the full chain of the certificate with all the revocation checks.


$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("My", "CurrentUser")
$store.Open('MaxAllowed');
$col = $store.Certificates.Find("FindByThumbprint", "c876012d1bb1f9e0487239b7686d6c41c465f7cb", $false);
$cert = $col[0];

$xChain = New-Object System.Security.Cryptography.X509Certificates.X509Chain;
$xChain.Build($cert);

$xChain.ChainElements | ForEach-Object {$_.Certificate}

Replace the thumbprint with the thumbprint of your certificate

Post a Comment

Previous Post Next Post