Sample code for 30+ languages & platforms
PowerShell

Load PFX/P12 File into Certificate Store Object

Demonstrates how to load a .pfx/.p12 into a certificate store object.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

$certStore = New-Object Chilkat.CertStore

# This only loads the contents of the PFX file into the certStore object.
# It is not importing the PFX into the Windows certificate stores.
$pfxPassword = "badssl.com"
$success = $certStore.LoadPfxFile("qa_data/pfx/badssl.com-client.p12",$pfxPassword)
if ($success -eq $false) {
    $($certStore.LastErrorText)
    exit
}

# Examine each certificate (loaded from the PFX) in this certStore object
$cert = New-Object Chilkat.Cert
$numCerts = $certStore.NumCertificates
$i = 0
while ($i -lt $numCerts) {
    $certStore.GetCert($i,$cert)
    $("hasPrivateKey=" + $cert.HasPrivateKey() + ", " + $cert.SubjectCN)
    $i = $i + 1
}