Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim cert As New Chilkat.Cert

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


Dim certStoreCU As New Chilkat.CertStore
Dim readOnlyFlag As Boolean = False

' "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
success = certStoreCU.OpenWindowsStore("CurrentUser","My",readOnlyFlag)
If (success = False) Then
    Debug.WriteLine("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 = False) Then
    Debug.WriteLine(certStoreCU.LastErrorText)
    Exit Sub
End If


Debug.WriteLine("Imported " & cert.SubjectCN)
Debug.WriteLine("Success.")