(Tcl) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
load ./chilkat.dll
# The LoadFromFile method will automatically detect the file format..
set cert [new_CkCert]
set success [CkCert_LoadFromFile $cert "qa_data/zatca/cert.pem"]
if {$success != 1} then {
puts [CkCert_lastErrorText $cert]
delete_CkCert $cert
exit
}
puts [CkCert_subjectCN $cert]
# Load the private key.
set privKey [new_CkPrivateKey]
set success [CkPrivateKey_LoadPemFile $privKey "qa_data/zatca/ec-secp256k1-priv-key.pem"]
if {$success != 1} then {
puts [CkPrivateKey_lastErrorText $privKey]
delete_CkCert $cert
delete_CkPrivateKey $privKey
exit
}
puts "Key Type: [CkPrivateKey_keyType $privKey]"
# Associate the private key with the certificate.
set success [CkCert_SetPrivateKey $cert $privKey]
if {$success != 1} then {
puts [CkCert_lastErrorText $cert]
delete_CkCert $cert
delete_CkPrivateKey $privKey
exit
}
puts "Success."
delete_CkCert $cert
delete_CkPrivateKey $privKey
|