2

I have an encrypted .eml file and a private key. I've looked it up a lot on the internet but couldn't find a way to decrypt the email using OpenSSL. I've tried this command:
smime -decrypt -in encrypted.eml -inkey privatekey.key -out decrypted.eml
and each time I get this error:

OpenSSL> smime -decrypt -in encrypted.eml -inkey privatekey.key -out decrypted.eml
No recipient certificate or key specified
smime: Use -help for summary.

I have also tried converting the private key to a .pem file but it still displays the same message. both files are in the same folder as the openssl.exe application is, before that I couldn't get it to work at all.

I clearly am doing something wrong, what is it exactly?

1
  • 1
    -inkey is an option and all options (must) begin with a hyphen. The privatekey file does need to be in PEM format inside, but it doesn't need to be named .pem unless you want to. Commented May 28, 2020 at 23:29

2 Answers 2

0

Try using openssl cms instead of openssl smime. See https://www.misterpki.com/openssl-cms/ for a good example.

1
  • 1
    I've tried that but I still get the same error: No recipient certificate or key specified Commented May 29, 2020 at 10:50
0

You are missing the -recip flag with your public key certificate file certificate.pem. From the OpenSSL docs:

-recip file the recipients certificate when decrypting a message. This certificate must match one of the recipients of the message or an error occurs.

So, please try the following:

openssl smime -decrypt -in encrypted.eml -recip certificate.pem -inkey privatekey.pem -out decrypted.eml 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.