entering password into openssl command from shell script

不羁岁月 提交于 2020-06-12 08:28:50

问题


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:


This one liner worked for me-

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


来源:https://stackoverflow.com/questions/27022180/entering-password-into-openssl-command-from-shell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!