7Şub
How to add MIME headers in encrypt and sign SMIME data using openssl smime command
I was trying to encrypt and sign MIME data using openssl smime command.
I have below MIME data -
From:"=?ISO-8859-1?B?3M0SEg=?=" <abc@dcc.final>
Subject:=?ISO-8859-1?B?yNA==?=
=?ISO-8859-1?B?3IDE4?=
=?ISO-8859-1?B?OjE0?=
To:<abc@gmail.com>
Message-ID:<FFCFac8b3-9160-4dc7-9263-220e87abd@hostn>
MIME-Version:1.0
Content-Type:Multipart/mixed;boundary="FFCF56959ff9-cc2b-48d6-9d9f-d4dad7885c53"
X-Mailer:UBC 4.0
--FFCF56959ff9-cc2b-48d6-9d9f-d4dad7885c53
Content-Type:text/plain;charset= ISO-8859-1
Content-Transfer-Encoding: base64
Content-Disposition:inline
U2NXIgTmFtZTogY2FjcGl2CkRhdGU6MjAyNC8wmKJJJSAxggGAMIIB
Mi8wNyAxODoxNApQYWdlczoxCkKLS0tLS0tLS0tLS0tmKJJJSAxgjj
LS0tLS0tLS0tLS0tLS0tLS0tLS0tZWxjb21lCg==mKKNIFIOE==KKO
--FFCF56959ff9-cc2b-48d6-9d9f-d4dad7885c53JNVFJNVFIORF
Content-Type:application/pdf
Content-Transfer-Encoding: base64
Content-Disposition:attachment;
filename="=?ISO-8859-1?B?DMjQw?=
=?ISO-8859-1?B?MjAjQw?=
=?ISO-8859-1?B?MgxNDQ0?=
=?ISO-8859-1?B?Lng==?="
JVBERi0xLjcKNCAwIG9Y2VzCjw8Ci9YT2JqZWN01MDZ+dq6i4UVJr9
Cjw8IC9QQUdFMDAwMSA3IDAgUiACj4+CmVuZG9i1MDZ+dq6i4JJKJN
IDAgb2JqCjw8Ci9S4wIDAuMCAwLjAgNzI1LjggR+Gt9T7RP4OWhjK0
.
.
Now I am encrypting this file using command - openssl smime -encrypt -aes256 -in input.txt -out encrypted.txt cert.pem
But the output encrypted data is as below without any headers (to , from , subject , Message-Id, Date and X-Mailer )
MIME-Version: 1.0
Content-Disposition: attachment; filename="smime.p7m"
Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Transfer-Encoding: base64
MIKYLAYJJJZIhUDKNIFNVTBgoJp0HX8irn9V0J3GZjXrn/gunr/DbW
kiaIk/IsZAEZFgVsb2NhbDEYMB1MDZ+dq6i4UVJr9zAw9+fYbJHIMK
.
.
and same encrypted data when signed using below command ,no headers are present in that too.
openssl smime -sign -in encrypted.txt -signer cert.pem -inkey key.pem -out out.txt
MIME-Version: 1.0
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----A410BFE85732BF0EEJIHI7EE27400531"
This is an S/MIME signed message
------A410BFE85732BF0EEJIHI7EE27400531
MIME-Version: 1.0
Content-Disposition: attachment; filename="smime.p7m"
Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Transfer-Encoding: base64
MIKYvAYJKoZIhvcNAQcDoIKYrTCCmKJJJSAxggGAMIIBfAIBADBkME0xFTATBgoJ
kiaJk/IsZAEZFgVsb2NhbDEYMBYGCgHHEomT8ixkARkWCG9jc3AyMDEyMRowGAYD
VQQDExFPQ1NQLVNTREstMjAxMi1DQQHHTwAAAOhWe3ZfbKVL5gAAAAAA6DANBgkq
.
.
How to add the headers(to , from , subject , Message-Id, Date and X-Mailer ) in encrypt or signed data? Need to change MIME data or command line flag to add. I could find "-to", "-from" and "-subject" flags but not for other headers.