5

I am trying to convert a p12 to a pem from a shell script without any user input. I can have the password as a variable within the script.

so when I call:

openssl pkcs12 -in *.p12 -out cert.pem -nodes

The terminal prints "Enter Import Password:" and waits for input.

I tried to pipe the password in with:

echo $PASS | openssl pkcs12 -in *.p12 -out cert.pem -nodes

as well as trying to use a flag with the openssl command but can't figure out how to do this.

3
  • What flag did you try? Commented Nov 19, 2014 at 16:52
  • 2
    Add -passin pass:12345678 to line Commented Nov 19, 2014 at 16:53
  • Thanks. I thought passin would only take a file as input...But I got it work with -password stdin, so openssl expects the password to come from stdin, then the pipe work. Commented Nov 20, 2014 at 17:50

1 Answer 1

7

This one liner worked for me-

openssl pkcs12 -in certificate.p12 -password pass:<your_password> -nodes | openssl x509 -noout -enddate
Sign up to request clarification or add additional context in comments.

1 Comment

You saved me, I was putting the password at the end of the line near the -enddate, but it should be before the pipe when opening the certificate. Note that new command is -passin instead of password as indicated above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.