(Visual Basic 6.0) Import a Certificate (.cer file) into a Windows Certificate Store
Demonstrates how to import a certificate (without private key) into a Windows certificate store.
Dim cert As New ChilkatCert
Dim success As Long
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."
|