Create S/Mime formatted PKCS#7 Signature

Sometimes it is not enough to create a plain ASN.1 coded PKCS#7 signatures. For example if the signature should be validated with free tools like Outlook Express/Windows Mail it is essential to create a PKCS#7 Signature in S/Mime format. Please see below a very simple VB6 sample on how to create such a signature: 

Dim smime As Object
Dim Files(0) As String
Dim BodyContent As String
Dim SMimeResult As String
Dim ReaderNumber As String

Set smime = CreateObject("aloahacsp.xml") 

ReaderNumber = 0  'for first cardreader, first certificate 

BodyContent = "Hello World" 

Files(0) = "c:\bla.pdf" 

If smime.make_PKCS7_mime(BodyContent, "", SMimeResult, ReaderNumber, "", Files) = True Then
        Call smime.writefile(SMimeResult, "c:\result.p7m")
End If

Set smime = Nothing

This function is also available in the PDF Signature SDK

you need to use function sign_file and the outputfilename needs to have the extension p7m.

Aloaha Software