VBScript Requires Chilkat v11.0.0+
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
set email = CreateObject("Chilkat.Email")
success = email.LoadEml("message.eml")
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
set cert = CreateObject("Chilkat.Cert")
success = cert.LoadPfxFile("signer.pfx","PFX_PASSWORD")
If (success <> 1) Then
outFile.WriteLine(cert.LastErrorText)
WScript.Quit
End If
success = email.SetSigningCert(cert)
If (success <> 1) Then
outFile.WriteLine(email.LastErrorText)
WScript.Quit
End If
email.SigningAlg = "pss"
email.SigningHashAlg = "sha256"
email.SendSigned = 1
set mail = CreateObject("Chilkat.MailMan")
mail.OpaqueSigning = 0
set rendered = CreateObject("Chilkat.BinData")
success = mail.RenderToMimeBd(email,rendered)
If (success <> 1) Then
outFile.WriteLine(mail.LastErrorText)
WScript.Quit
End If
success = rendered.WriteFile("signed.eml")
If (success <> 1) Then
outFile.WriteLine("Failed: rendered.WriteFile.")
WScript.Quit
End If
outFile.WriteLine("Saved signed.eml.")
outFile.Close