Go Requires Chilkat v11.8.0+
Go
Inspect S/MIME protection when loading an email
See more Email Object Examples
Load a signed or encrypted message and inspect each layer the parser encountered. Register the recipient's certificate and private key first (AddPemSource) for encrypted input. SignaturesValid reports the cryptographic verification result. Applications that rely on signer identity must also validate the certificate and their trust policy.
Chilkat Go Downloads
success := false
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := chilkat.NewEmail()
// For encrypted input, register the matching certificate and private key (here from a PEM file)
// before LoadEml:
// new Pem pem;
// success = pem.LoadPemFile("recipient.pem","PEM_PASSWORD");
// success = email.AddPemSource(pem);
success = email.LoadEml("signed.eml")
if success != true {
fmt.Println(email.LastErrorText())
email.DisposeEmail()
return
}
fmt.Println("Encryption layer present: ", email.ReceivedEncrypted())
if email.ReceivedEncrypted() == true {
fmt.Println("Decrypted: ", email.Decrypted())
}
fmt.Println("Signature layer present: ", email.ReceivedSigned())
if email.ReceivedSigned() == true {
fmt.Println("Signature verified: ", email.SignaturesValid())
if email.SignaturesValid() == true {
fmt.Println("Signer: ", email.SignedBy())
}
}
email.DisposeEmail()