Xojo Plugin Requires Chilkat v11.8.0+
Xojo Plugin
Decrypt an S/MIME email and verify its signature
See more Email Object Examples
Register the recipient’s certificate and private key (from a PEM file) before opening signed-encrypted.eml. This workflow expects both encryption and a signature, so it checks both layers before reading the message. Cryptographic signature validity is one input to a signer-trust decision.
Chilkat Xojo Plugin Downloads
Dim success As Boolean
success = False
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim email As New Chilkat.Email
// The recipient's certificate and private key are in a PEM file. The 2nd argument of LoadPemFile
// is the password of the private key.
Dim pem As New Chilkat.Pem
success = pem.LoadPemFile("recipient.pem","RECIPIENT_PASSWORD")
If (success <> True) Then
System.DebugLog(pem.LastErrorText)
Return
End If
success = email.AddPemSource(pem)
If (success <> True) Then
System.DebugLog(email.LastErrorText)
Return
End If
success = email.LoadEml("signed-encrypted.eml")
If (success <> True) Then
System.DebugLog(email.LastErrorText)
Return
End If
If ((email.ReceivedEncrypted <> True) Or (email.Decrypted <> True)) Then
System.DebugLog("Expected a successfully decrypted S/MIME envelope.")
Return
End If
If ((email.ReceivedSigned <> True) Or (email.SignaturesValid <> True)) Then
System.DebugLog("Expected a valid signature inside the envelope.")
Return
End If
// This message has one signer. Examine its certificate after verification.
Dim signer As New Chilkat.Cert
success = email.LastSignerCert(0,signer)
If (success <> True) Then
System.DebugLog(email.LastErrorText)
Return
End If
System.DebugLog("Signer certificate: " + signer.SubjectDN)
System.DebugLog("Recovered subject: " + email.Subject)
System.DebugLog("Recovered attachments: " + Str(email.NumAttachments))