我正在尝试使用以下命令连接到服务器:
openssl s_client -connect xx.xx.xx.xx:443
错误:
CONNECTED(00000005)
depth=0 L = XXXXXXX
verify error:num=20:**unable to get local issuer certificate**
verify return:1
depth=0 L = XXXXXXXX
verify error:num=21:**unable to verify the first certificate
verify return:1**
---
Certificate chain
0 s:/L=XXXX
i:/C=XXXX
---
Server certificate
-----BEGIN CERTIFICATE-----
....
...
..
<removed cert>
..
...
....
-----END CERTIFICATE-----
subject=xxxxxxx CN=*xxx.xom
issuer=XXXX CA
---
No client certificate CA names sent
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 2281 bytes and written 326 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES256-GCM-SHA384
Session-ID: 52A27BC97001D52A7DA4A73FBA87C7DD2902A0C55B0AE9FAA87A3A8DBA94A7CE
Session-ID-ctx:
Master-Key: ECD435DCDD59B2BAD50A1BF8BAEA39E68058524A082DC219CEE290DB7A80A37AE4E763DF7FA
TLS session ticket lifetime hint: 300 (seconds)
TLS session ticket:
0000 - 5d b4 5c fe ca 2d 54 2e-31 49 74 a6 18 a7 3a f5 ].\..-T.1It...:.
XXXX
0080 - ab 5c 0a bc 45 9c 10 01-9f 3b ce 6e ee 1a a6 99 .\..E....;.n....
0090 - 04 81 ea e0 be a5 91 a2-18 09 d4 b8 90 b7 c7 50 ...............P
00a0 - f7 7d 73 e5 b1 3d 0d 58-20 07 78 7b 57 c4 34 58 .}s..=.X .x{W.4X
Start Time: 1566410644
Timeout : 7200 (sec)
**Verify return code: 21 (unable to verify the first certificate)**
---
因此,该命令似乎正在尝试验证我不需要的证书。如何绕过验证? 有没有类似于curl -k 标志的东西?
答案 0 :(得分:0)
OpenSSL的s_client
绝不会以错误的证书终止,除非您也使用
要求他使用
-verify_return_error
参数(@bartonjs在评论中已经建议)。
您可以在手册页man 1 s_client
或online中了解有关它的更多信息。在注释中查找-verify
参数或更高版本:
如果在验证服务器证书时遇到问题,则
-showcerts
选项可用于显示服务器发送的所有证书。
s_client
实用程序是一种测试工具,旨在继续进行握手 在任何证书验证错误之后。结果,它将接受任何 对等方发送的证书链(信任与否)。无测试应用 不应这样做,因为这会使他们容易受到MITM攻击。这个 行为可以通过-verify_return_error
选项进行更改:任何验证 然后返回错误,中止握手。
如果您看到的结果是您看到的最后一个“错误”,则可能是服务器上的其他东西正在此时终止连接。您应该在Web服务器日志中看到原因。