Sample code for 30+ languages & platforms
Xojo Plugin Requires Chilkat v11.0.0+

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 Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim email As New Chilkat.Email
success = email.LoadEml("message.eml")
If (success <> True) Then
    System.DebugLog(email.LastErrorText)
    Return
End If

Dim cert As New Chilkat.Cert
success = cert.LoadPfxFile("signer.pfx","PFX_PASSWORD")
If (success <> True) Then
    System.DebugLog(cert.LastErrorText)
    Return
End If

success = email.SetSigningCert(cert)
If (success <> True) Then
    System.DebugLog(email.LastErrorText)
    Return
End If

email.SigningAlg = "pss"
email.SigningHashAlg = "sha256"
email.SendSigned = True
Dim mail As New Chilkat.MailMan
mail.OpaqueSigning = False
Dim rendered As New Chilkat.BinData
success = mail.RenderToMimeBd(email,rendered)
If (success <> True) Then
    System.DebugLog(mail.LastErrorText)
    Return
End If

success = rendered.WriteFile("signed.eml")
If (success <> True) Then
    System.DebugLog("Failed: rendered.WriteFile.")
    Return
End If

System.DebugLog("Saved signed.eml.")