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?
    – S.L. Barth
    Jun 4 '15 at 8:07
  • 1
    Edited post with code sample i used Jun 4 '15 at 8:22

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 '15 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.