Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to pass in the subject's key from stdin when creating CSRs with OpenSSL?

Like in the following (non-working)

openssl req -new -key stdin -subj '/C=US/ST=NY/L=Somewhere/organizationName=MyOrg/OU=MyDept/'


-key stdin

part is not working.

I want to use OpenSSL for CSR and certificate creating in a scripting environment, and both keys and subject information are coming from a database.

share|improve this question
up vote 6 down vote accepted

*nix commands usually use a dash to represent stdin or stdout in the context of file parameters, so -key - is supposed to read the key from stdin. However, it seems that openssl doesn't implement this. Luckily, in Linux pretty much everything is a file, including stdin which can be accessed as /dev/stdin (which is actually a symlink to /proc/self/fd/0), so the following works:

openssl req -new -key /dev/stdin
share|improve this answer
neat! just tested: works also on FreeBSD. – oberstet Jun 2 '12 at 1:05
Neat. I have solved this in the past using Unix Named Pipes, but just using /dev/stdin is a good solution. – Duke May 10 '15 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .