Tcl
Tcl
Use an XmlCertVault for S/MIME Operations
See more MIME Examples
Loads a CMS/PKCS #7 encrypted S/MIME message and decrypts it back to the original MIME content.
UseCertVault sets an XmlCertVault as the single active source of certificates and private keys for S/MIME encryption, decryption, signing, and verification.
The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background. A certificate vault is a convenient container for one or more certificates and keys. Only one vault is active at a time; assigning a new vault replaces the previous one.
Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
set mime [new_CkMime]
set success [CkMime_LoadMimeFile $mime "qa_data/encrypted.eml"]
if {$success == 0} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
exit
}
# Use an XmlCertVault as the source of certificates and private keys for S/MIME operations. The
# only argument is the vault. Only one vault is active at a time.
set vault [new_CkXmlCertVault]
set pfxPassword "myPfxPassword"
set success [CkXmlCertVault_AddPfxFile $vault "qa_data/recipient.pfx" $pfxPassword]
if {$success == 0} then {
puts [CkXmlCertVault_lastErrorText $vault]
delete_CkMime $mime
delete_CkXmlCertVault $vault
exit
}
set success [CkMime_UseCertVault $mime $vault]
if {$success == 0} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
delete_CkXmlCertVault $vault
exit
}
# Decryption (and signing/verification) now draws credentials from the vault.
set success [CkMime_Decrypt $mime]
if {$success == 0} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
delete_CkXmlCertVault $vault
exit
}
puts "Decrypted using the certificate vault."
delete_CkMime $mime
delete_CkXmlCertVault $vault