Sample code for 30+ languages & platforms
Visual Basic 6.0

Import a Certificate (.cer file) into a Windows Certificate Store

See more Certificates Examples

Demonstrates how to import a certificate (without private key) into a Windows certificate store.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

Dim cert As New ChilkatCert

success = cert.LoadFromFile("qa_data/certs/example.cer")
If (success = 0) Then
    Debug.Print cert.LastErrorText
    Exit Sub
End If

Dim certStoreCU As New ChilkatCertStore
Dim readOnlyFlag As Long
readOnlyFlag = 0

' "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
success = certStoreCU.OpenWindowsStore("CurrentUser","My",readOnlyFlag)
If (success = 0) Then
    Debug.Print "Failed to open the CurrentUser/My certificate store for read/write."
    Exit Sub
End If

' Import the certificate into the CurrentUser/My certificate store.
success = certStoreCU.AddCertificate(cert)
If (success = 0) Then
    Debug.Print certStoreCU.LastErrorText
    Exit Sub
End If

Debug.Print "Imported " & cert.SubjectCN
Debug.Print "Success."