entering password into openssl command from shell script

16.9k views Asked by At

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.

1

There are 1 answers

1
Sankalp On

This one liner worked for me-

openssl pkcs12 -in certificate.p12 -password pass:<your_password> -nodes | openssl x509 -noout -enddate