Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to decrypt S/MIME file using Openssl

I am openssl Newibe. I am trying to write a python script (calling openssl) to decrypt multiple p12 encrypted eml files but failing.

I can open them up in Thunderbird fine.

here is what i tried:

openssl pkcs12 -in keys/pkitepki.p12 -clcerts -nokeys -out file.crt.pem
openssl pkcs12 -in keys/pkitepki.p12 -nocerts -out file.key.pem
openssl smime -decrypt -in smime.p7m -recip file.crt.pem  -inkey file.key.pem 

The error i got is :

Error reading S/MIME message
139955665413864:error:0D0D40D1:asn1 encoding routines:SMIME_read_ASN1:no content type:asn_mime.c:451

What is wrong with my steps?

like image 387
Phyo Arkar Lwin Avatar asked Dec 30 '25 15:12

Phyo Arkar Lwin


1 Answers

The input should not be smime.p7m. it should be the email with the smime.p7m inside it. There should be email headers and a base64 encoded content.

like image 119
Jake Avatar answered Jan 01 '26 04:01

Jake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!