(Visual Basic 6.0) Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.
Dim certStore As New ChilkatCertStore
' 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
pfxPassword = "badssl.com"
Dim success As Long
success = certStore.LoadPfxFile("qa_data/pfx/badssl.com-client.p12",pfxPassword)
If (success = 0) Then
Debug.Print certStore.LastErrorText
Exit Sub
End If
' Examine each certificate (loaded from the PFX) in this certStore object
Dim numCerts As Long
numCerts = certStore.NumCertificates
Dim i As Long
i = 0
Do While i < numCerts
Dim cert As ChilkatCert
Set cert = certStore.GetCertificate(i)
Debug.Print "hasPrivateKey=" & cert.HasPrivateKey() & ", " & cert.SubjectCN
i = i + 1
Loop
|