17

The following request to openssl hangs

openssl req -key server.key -out server.csr 

Any idea what the problem could be?

elitalon
  • 8,523
  • 9
  • 47
  • 84
Prakash Raman
  • 11,331
  • 26
  • 71
  • 124

2 Answers2

78

I had the same issue when using GitBash in Windows 7, After hours of search this solved my issue:

winpty openssl genrsa -out ../private.pem -aes256 4096

Could give you some idea what is needed.

Zuhayer Tahir
  • 1,420
  • 1
  • 10
  • 20
  • 8
    +1 and to note that my full command was different, but the key was placing "winpty" before the full openssl command. I believe winpty adjusts standard input and/or adds mouse support which is required for some randomness that openssl uses to generate the key. Otherwise it just hangs waiting for input which never comes (even if you type keystrokes or move the mouse). – eselk Aug 03 '17 at 00:48
  • 1
    this also helped me... how did you find that you need prefix command with winpty? what is winpty? – Patlatus Nov 30 '17 at 13:09
  • 1
    @Patlatus How did I find? = same as you = stackoverflow; don't know anything about winpty, tried to understand at the time but could not; so I said the heck with it, as long as it works. – Zuhayer Dec 04 '17 at 03:20
  • https://superuser.com/questions/1273181/why-do-i-need-prefix-openssl-with-winpty-on-windows-bash In case someone has the same question, basically because bash default is mintty which cant run openssl because of some conversions, so we use winpty for that – mouchin777 Apr 01 '20 at 10:36
  • 1
    I was using this answer (https://stackoverflow.com/a/60516812/2567273) to create my own key and used this answer to git it working – Luminous Jan 26 '21 at 19:07
  • using winpty helped me. Thanks – user804401 Mar 12 '21 at 05:13
24

You need another argument, it expects to read a certificate from standard input. Probably you meant to add -new as a command line argument, or you need to pass an existing certificate on standard in.

Ivo
  • 3,361
  • 1
  • 22
  • 28