Search code examples
openssl

How can I pass in multiple answers into openssl shell command?


When I run openssl req -new -key key.pem -out csr.pem it prompts me for several answers (address, name, country code etc...). When this is inside of a script how can I pass in these answers?

This:

RUN echo "something" | openssl req -new -key key.pem -out csr.pem

Only answers the first question, but then the command fails since it didn't get any other answer.


Solution

  • You can pass it the -subj argument to which you can pass the details

    -subj "/C=US/ST=STATE/L=CITY/O=ORG_NAME/OU=OU_NAME/CN=CN_OR_FQDN_OR_SERVER_NAME"