Is it possible to specify Header information in S/MIME files?


I encrypt a file with this command:

gpgsm -a --base64 -r 0xF9999999 --disable-polic
y-checks --log-file data\log.txt --audit-log data\audit.txt --disable-crl-ch
ecks -o data\test-base64.p7m -e data\test.xml

We use X.509.

I wonder if there is a way to specify header information about MÌME in the output file.

Content-ID: {AAAAAAA-2222-4444-9999-FAAAAAAAAAAA}
MIME-Version: 1.0
Content-type: application/x-pkcs7-mime; smime-type=enveloped-data; name=“smime.p7m”
Content-Transfer-Encoding: base64

Especially “MIME-Version” is important for us.



If I understand you correctly you are asking if you can store arbitrary information before the actual encrypted content. No GPGSM does not support this directly as gpgsm is focused on the Encryption.

You can of course “chain” gpgsm with other commands with Windows CMD or PowerShell tools.

From the top of my head I would try something like:

echo “Content-ID: {AAAAAAA-2222-4444-9999-FAAAAAAAAAAA}” > data\test-base64.p7m
echo “” >> data\test-base64.p7m
echo “MIME-Version: 1.0” >> data\test-base64.p7m
echo “Content-type: application/x-pkcs7-mime; smime-type=enveloped-data; name=“smime.p7m”” >> data\test-base64.p7m
echo “Content-Transfer-Encoding: base64” >> data\test-base64.p7m

gpgsm -a --base64 -r 0xF9999999 --disable-polic
y-checks --log-file data\log.txt --audit-log data\audit.txt --disable-crl-ch
ecks -e data\test.xml >> data\test-base64.p7m

There are of course better ways to do this but you can probably see the point: The output of GpgSM is just data and you can add what you want before this with other tools.

Hi Jo,

gpgsm only creates a CMS file, you would need a mail application to create a MIME mail.
(And as far as I know there is only “MIME-Version: 1.0”. You may refer to a specific S/MIME revision.)


Thanks for the answer Andre and Bernhard