(VB.NET) Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object. Note: This example requires Chilkat v10.1.2 or greater.
Dim certStore As New 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.
Dim pfxPassword As String = "badssl.com"
Dim success As Boolean = certStore.LoadPfxFile("qa_data/pfx/badssl.com-client.p12",pfxPassword)
If (success = False) Then
Debug.WriteLine(certStore.LastErrorText)
Exit Sub
End If
' Examine each certificate (loaded from the PFX) in this certStore object
Dim cert As New Chilkat.Cert
Dim numCerts As Integer = certStore.NumCertificates
Dim i As Integer = 0
While i < numCerts
certStore.GetCert(i,cert)
Debug.WriteLine("hasPrivateKey=" & cert.HasPrivateKey() & ", " & cert.SubjectCN)
i = i + 1
End While
|