My knownledge about security is limited so I need some help here.

The Question

I want to Decrypt a .P7M file using its private key (.pem). I would prefer to use OpenSSL for this.

Tried so far

OpenSSL smime -decrypt -in "Secret.p7m" -inkey "Key.pem" > Result.txt


unable to load signing key file
7548:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\pem_lib
.c:701:Expecting: ANY PRIVATE KEY
error in smime**The P7M File**

Content-Type: application/pkcs7-mime; name="smime.p7m"; smime-type=enveloped-data
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7m"
Content-Description: S/MIME Encrypted Message


  • "Cannot seem to get it to work". What command did you use, and what was the result? Any error messages? Jun 4, 2015 at 8:07
  • 1
    Edited post with code sample i used Jun 4, 2015 at 8:22

2 Answers 2


Your decryption command is correct.

It seems there's something wrong with your key file. Does it really start with -----BEGIN RSA PRIVATE KEY----- and end with -----END RSA PRIVATE KEY----- (mind the exact number of dashes)? Or is it perhaps DER encoded which requires you to add -keyform DER your decryption command line?

BTW: You can check the integrity of the key itself with openssl rsa -in Key.pem

  • Checking the integrity is fine. The output gives me -----BEGIN RSA PRIVATE KEY---- BLABLABALABALBALABALBA -----END RSA PRIVATE KEY----- Jun 4, 2015 at 10:34

I have run into this same issue and Lupo's answer is on the right track. You can try converting the key using a command like:

openssl pkcs12 -in <key file.p7m> -out <key_file.pem> -nodes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .