(Tcl) Load Certificate from .cer and Private Key from .pem
Load a certificate from a .cer and its associated private key from a .pem.
load ./chilkat.dll
set cert [new_CkCert]
set success [CkCert_LoadFromFile $cert "C:/certs_and_keys/Certificate.cer"]
if {$success == 0} then {
puts [CkCert_lastErrorText $cert]
delete_CkCert $cert
exit
}
set sbPem [new_CkStringBuilder]
set success [CkStringBuilder_LoadFile $sbPem "C:/certs_and_keys/PrivateKey.pem" "utf-8"]
if {$success == 0} then {
puts "Failed to load private key PEM"
delete_CkCert $cert
delete_CkStringBuilder $sbPem
exit
}
set success [CkCert_SetPrivateKeyPem $cert [CkStringBuilder_getAsString $sbPem]]
if {$success == 0} then {
puts [CkCert_lastErrorText $cert]
delete_CkCert $cert
delete_CkStringBuilder $sbPem
exit
}
puts "The certificate and associated private key are now loaded and ready for signing."
delete_CkCert $cert
delete_CkStringBuilder $sbPem
|