B4X Requires Chilkat v11.0.0+
B4X
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 B4X Downloads
Dim success As Boolean = False
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim email As ChilkatEmail
email.Initialize
success = email.LoadEml("message.eml")
If success <> True Then
Log(email.LastErrorText)
Return
End If
Dim cert As ChilkatCert
cert.Initialize("cert")
success = cert.LoadPfxFile("signer.pfx", "PFX_PASSWORD")
If success <> True Then
Log(cert.LastErrorText)
Return
End If
success = email.SetSigningCert(cert)
If success <> True Then
Log(email.LastErrorText)
Return
End If
email.SigningAlg = "pss"
email.SigningHashAlg = "sha256"
email.SendSigned = True
Dim mail As ChilkatMailMan
mail.Initialize("mail")
mail.OpaqueSigning = False
Dim rendered As ChilkatBinData
rendered.Initialize
success = mail.RenderToMimeBd(email, rendered)
If success <> True Then
Log(mail.LastErrorText)
Return
End If
success = rendered.WriteFile("signed.eml")
If success <> True Then
Log("Failed: rendered.WriteFile.")
Return
End If
Log("Saved signed.eml.")