Sample application for PKCS#7/CMS/SMIME signature creation with Pkcs11Interop, BouncyCastle and MimeKit libraries.
Pkcs7SignatureGenerator.exe
--pkcs11-library "softhsm2.dll"
--list-tokens
Pkcs7SignatureGenerator.exe
--pkcs11-library "softhsm2.dll"
--list-objects
--token-serial "864c60e98638f74e"
--token-label "My token 1"
--pin "11111111"
Pkcs7SignatureGenerator.exe
--pkcs11-library "softhsm2.dll"
--sign
--token-serial "864c60e98638f74e"
--token-label "My token 1"
--pin "11111111"
--key-label "John Doe"
--key-id "4A6F686E20446F65"
--data-file "c:\temp\document.txt"
--signature-file "c:\temp\document.p7s"
--hash-alg "SHA256"
--signature-scheme "RSASSA_PKCS1_v1_5"
--output-format "CMS"
--certs-dir "c:\temp\additional-certs"
openssl.exe
cms
-verify
-binary
-inform DER
-in "c:\temp\document.p7s"
-content "c:\temp\document.txt"
-noverify
> nul
Pkcs7SignatureGenerator.exe
--pkcs11-library "softhsm2.dll"
--sign
--token-serial "864c60e98638f74e"
--token-label "My token 1"
--pin "11111111"
--key-label "John Doe"
--key-id "4A6F686E20446F65"
--data-file "c:\temp\document.txt"
--signature-file "c:\temp\document.eml"
--hash-alg "SHA256"
--signature-scheme "RSASSA_PKCS1_v1_5"
--output-format "SMIME"
--certs-dir "c:\temp\additional-certs"
openssl.exe
smime
-verify
-in "c:\temp\document.eml"
-noverify
> nul