openssl挂起并且不退出

Adi*_*boy 38 openssl cmd quit

我正在尝试使用openssl来获取证书,它似乎一直在悬挂.我做了很多研究,但并非所有可用的选项似乎都适用于Windows.

openssl s_client -showcerts -connect google.com:443 > cert.txt
Run Code Online (Sandbox Code Playgroud)

我试过这个:

openssl s_client -connect xyz:443 < quit.txt > cert.txt
Run Code Online (Sandbox Code Playgroud)

其中quit.txt包含来自http://bytes.com/topic/php/answers/8802-automate-openssl-s_client-command-batch-php-script的 "quit \n"

那没用.我还查看了Openssl s_clinet -connect脚本.强制退出帮助

我也试过了 -prexit

我也研究过这个问题并且无法使用它:https: //serverfault.com/questions/139728/how-to-download-ssl-certificate-from-a-website

我做得很好!我设法做一些事情,我认为将是不可能的,这样的错误一件简单的事情设法阻止我暂且 :(

Gle*_*ner 67

在Windows上,只需winpty在openssl命令之前键入即可.因此,例如,您可以创建如下证书:

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

  • 在Windows 7的Git Bash中为我工作! (3认同)
  • 非常感谢!!!!我花了多少时间来弄清楚为什么这么小的命令行不能在我的Windows上工作...... !!! (2认同)
  • 对于包括我自己在内的一些人来说:“‘winpty’不被识别为内部或外部命令、可操作程序或 Bath 文件。” (2认同)

MBu*_*MBu 21

看起来Windows的一些OpenSSL发行版期望额外的按键,独立于标准输入.Quit.txt被正确地传送到openssl的STDIN(服务器接收QUIT命令),但是在按任意键之前没有任何反应.

Cygwin的 OpenSSL版本中不存在此问题.不幸的是,Cygwin的基本安装需要大约100 MB的磁盘空间,但您可以尝试仅提取openssl.exe和所需的库.

此方法有效:

echo QUIT | c:\cygwin\bin\openssl.exe s_client -showcerts -connect google.com:443 > cert.txt
Run Code Online (Sandbox Code Playgroud)


cra*_*fty 8

如果在Windows上的mingw64下运行,您可以使用winpty程序正确包装终端

例如,在bash别名下创建别名openssl ='winpty openssl.exe'

然后openssl s_client -connect blah

应该按预期工作

  • 或者只是在openssl之前键入winpty.这对我有用.谢谢. (8认同)

Ste*_*ens 6

如果您只是运行 openssl 命令,当它似乎挂起时,只需继续按 Enter 键,它最终会继续显示提示。每当你遇到另一个挂起的情况时,只要继续按 Enter 键,最终它就会完成工作。在下面的输出中,您可以看到它在“位置名称”和“通用名称”之后挂起的位置,并且空行大致表示我按 Enter 键以使其转到下一个提示的次数。

PS C:\somedir> openssl req -x509 -new -nodes -key rootSSL.key -sha256 -days 1024 -out rootSSL.pem
Enter pass phrase for rootSSL.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:Delaware
Locality Name (eg, city) []:Newark



Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:localhost



Email Address []:
PS C:\somedir> ls


    Directory: C:\somedir


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         12/6/2023   4:32 PM           1884 rootSSL.key
-a----         12/6/2023   4:35 PM           1382 rootSSL.pem
Run Code Online (Sandbox Code Playgroud)