B4X
B4X
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 B4X Downloads
Dim success As Boolean = False
Dim cert As ChilkatCert
cert.Initialize("cert")
success = cert.LoadFromFile("qa_data/certs/example.cer")
If success = False Then
Log(cert.LastErrorText)
Return
End If
Dim certStoreCU As ChilkatCertStore
certStoreCU.Initialize
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
Log("Failed to open the CurrentUser/My certificate store for read/write.")
Return
End If
' Import the certificate into the CurrentUser/My certificate store.
success = certStoreCU.AddCertificate(cert)
If success = False Then
Log(certStoreCU.LastErrorText)
Return
End If
Log("Imported " & cert.SubjectCN)
Log("Success.")