Sample code for 30+ languages & platforms
Visual Basic 6.0

Load PFX/P12 File into Certificate Store Object

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

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

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"
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 cert As New ChilkatCert
Dim numCerts As Long
numCerts = certStore.NumCertificates
Dim i As Long
i = 0
Do While i < numCerts
    success = certStore.GetCert(i,cert)
    Debug.Print "hasPrivateKey=" & cert.HasPrivateKey() & ", " & cert.SubjectCN
    i = i + 1
Loop