Signs the message to a Multipart/Signed message.
Syntax:
Returns:
Returns 1 if the operation is successful; otherwise returns 0 if the operation fails.
Remarks:
The entire message - header and body - are signed to a Cryptographic Message Syntax (CMS) SignedData format. The entire original message, and the signed data are saved for later. The contents of this message is then erased so as to be replaced with new content. The following new set of headers replace the old set:
- MIME-Version: 1.0
- Date: <Current Date>
- Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=md5; boundary="fredi.boundary.mult.sig"
Additionally, exactly 2 body parts are created:
- The Protected Data body part. The entire original message is copied to this body part.
- The Signature body part. The signed data is store in the body of this body part, and the following headers are added:
- Content-Type: application/pkcs7-signature; name=smime.p7s
- Content-Disposition: attachment; filename=smime.p7s
- Content-Transfer-Encoding: binary
For alternate security settings, apply different parameters on the ediSecurity object that can be accessed using the GetSecurity method.
Example:
Dim oEdiDoc As Fredi.ediDocument
Dim oMailDocument As Fredi.mailDocument
Dim oMessage As Fredi.mailMessage
Dim oSecurity As Fredi.ediSecurity
Dim oSecurities As Fredi.ediSecurities
' Create instance of Framework EDI.
Set oEdiDoc = New Fredi.ediDocument
' Get securities.
Set oSecurities = oEdiDoc.GetSecurities
' Set the default certificate store
oSecurities.DefaultCertSystemStoreName = ksCertStoreName ' Case sensitive
' Set the default certificate store location
oSecurities.DefaultCertSystemStoreLocation = ksCertStoreLocation
' Get internet mail document object
Set oMailDocument = oEdiDoc.GetMailDocument
' Disable auto-processing so that message can be secure as is.
oMailDocument.Option(MailDocOpt_Auto) = 0
' Load the mail document
oMailDocument.Load App.Path & "\SampleMail.TXT"
' Get the message.
Set oMessage = oMailDocument.GetMessage
' Get the security, and specify certificate used to encrypt.
Set oSecurity = oMessage.GetSecurity
oSecurity.CertificateSignerName = ksCertSubjectName
' Encrypt message.
oMessage.PrepareMultipartSigned
oMessage.Save App.Path & "\MultipartSignedOutput.TXT"
MsgBox "Done"
Sample
See Also.
RFC 1847 - Security Multiparts for MIME: Multipart/Signed and Multipart/Encrypted