Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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/CN=fqdn.of.my.host'

The

-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

1 Answer 1

up vote 4 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.