openssl hangs and does not exit

前端 未结 4 1234
失恋的感觉
失恋的感觉 2020-12-24 01:49

I am trying to use openssl to get a certificate, and it seems to keep hanging. I have done a lot of research but not all of the available options seem to work on Windows.

相关标签:
4条回答
  • 2020-12-24 02:14

    For reasons i do not completeley understand, echoing QUIT or quit\n into the input did not work in my case. I'm using MINGW64 with OpenSSL 1.0.2d on Windows 8.1, and i'm using openssl to get certificates from servers inside a bash script. However, just running the openssl command in background and waiting a bit worked for me:

    #!/bin/bash
    
    openssl s_client -connect my.server.com:443 -showcerts > output.txt 2>/dev/null &
    sleep 2
    
    0 讨论(0)
  • 2020-12-24 02:22

    If running under mingw64 on windows you can use the winpty program to correctly wrap the terminal

    Eg creating alias under bash alias openssl='winpty openssl.exe'

    Then openssl s_client -connect blah

    Should work as expected

    0 讨论(0)
  • 2020-12-24 02:30

    It looks like some OpenSSL distributions for Windows are expecting an additional keypress, independant of standard input. Quit.txt gets correctly piped into openssl's STDIN (the server receives QUIT command), but nothing happens until you press any key.

    This problem does not exist in Cygwin's version of OpenSSL. Unfortunatly base installation of Cygwin takes about 100 MB of disk space, but you can try to extract only openssl.exe and required libraries.

    This method works:

    echo QUIT | c:\cygwin\bin\openssl.exe s_client -showcerts -connect google.com:443 > cert.txt
    
    0 讨论(0)
  • 2020-12-24 02:37

    On windows, simply typing winpty before your openssl command will do the trick. So, for example, you could create a certificate like so:

    winpty openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX

    0 讨论(0)
提交回复
热议问题