(PowerShell) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within. Note: This example requires Chilkat v10.1.2 or greater.
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$certStore = New-Object Chilkat.CertStore
$pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
$pfxPassword = "test"
$success = $certStore.LoadPfxFile($pfxPath,$pfxPassword)
if ($success -ne $true) {
$($certStore.LastErrorText)
exit
}
$numCerts = $certStore.NumCertificates
$("PFX contains " + $numCerts + " certificates")
$cert = New-Object Chilkat.Cert
$i = 0
while ($i -lt $numCerts) {
$certStore.GetCert($i,$cert)
$([string]$i + ": (Common Name) " + $cert.SubjectCN)
$([string]$i + ": (Serial Number) " + $cert.SerialNumber)
$([string]$i + ": (Distinguished Name) " + $cert.SubjectDN)
$i = $i + 1
}
|