CkPython Requires Chilkat v11.0.0+
CkPython
Sign an EML using RSA-PSS and SHA-256
See more Email Object Examples
Load the intended signing certificate and its RSA private key from a PFX. Set the signature options on Email and render the final S/MIME message through MailMan. The resulting multipart/signed file can be verified independently. Supply the PFX password through your application’s credential store.
Chilkat CkPython Downloads
import sys
import chilkat
success = False
# Assumes Chilkat is unlocked. See Global Unlock Sample.
email = chilkat.CkEmail()
success = email.LoadEml("message.eml")
if (success != True):
print(email.lastErrorText())
sys.exit()
cert = chilkat.CkCert()
success = cert.LoadPfxFile("signer.pfx","PFX_PASSWORD")
if (success != True):
print(cert.lastErrorText())
sys.exit()
success = email.SetSigningCert(cert)
if (success != True):
print(email.lastErrorText())
sys.exit()
email.put_SigningAlg("pss")
email.put_SigningHashAlg("sha256")
email.put_SendSigned(True)
mail = chilkat.CkMailMan()
mail.put_OpaqueSigning(False)
rendered = chilkat.CkBinData()
success = mail.RenderToMimeBd(email,rendered)
if (success != True):
print(mail.lastErrorText())
sys.exit()
success = rendered.WriteFile("signed.eml")
if (success != True):
print("Failed: rendered.WriteFile.")
sys.exit()
print("Saved signed.eml.")