Sample code for 30+ languages & platforms
Tcl

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 Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set cert [new_CkCert]

set success [CkCert_LoadFromFile $cert "qa_data/certs/example.cer"]
if {$success == 0} then {
    puts [CkCert_lastErrorText $cert]
    delete_CkCert $cert
    exit
}

set certStoreCU [new_CkCertStore]

set readOnlyFlag 0

# "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
set success [CkCertStore_OpenWindowsStore $certStoreCU "CurrentUser" "My" $readOnlyFlag]
if {$success == 0} then {
    puts "Failed to open the CurrentUser/My certificate store for read/write."
    delete_CkCert $cert
    delete_CkCertStore $certStoreCU
    exit
}

# Import the certificate into the CurrentUser/My certificate store.
set success [CkCertStore_AddCertificate $certStoreCU $cert]
if {$success == 0} then {
    puts [CkCertStore_lastErrorText $certStoreCU]
    delete_CkCert $cert
    delete_CkCertStore $certStoreCU
    exit
}

puts "Imported [CkCert_subjectCN $cert]"
puts "Success."

delete_CkCert $cert
delete_CkCertStore $certStoreCU