Sample code for 30+ languages & platforms
Chilkat2-Python

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 Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

cert = chilkat2.Cert()

success = cert.LoadFromFile("qa_data/certs/example.cer")
if (success == False):
    print(cert.LastErrorText)
    sys.exit()

certStoreCU = chilkat2.CertStore()
readOnlyFlag = 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):
    print("Failed to open the CurrentUser/My certificate store for read/write.")
    sys.exit()

# Import the certificate into the CurrentUser/My certificate store.
success = certStoreCU.AddCertificate(cert)
if (success == False):
    print(certStoreCU.LastErrorText)
    sys.exit()

print("Imported " + cert.SubjectCN)
print("Success.")