【问题标题】:How to ignore certificate verification while using openssl s_client connect?使用 openssl s_client 连接时如何忽略证书验证?
【发布时间】:2019-12-27 01:24:02
【问题描述】:

我正在尝试使用以下命令连接到服务器:

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 标志的东西?

【问题讨论】:

  • 它终止了吗? AFAIK s_client 命令将其打印为只是提供信息,然后继续使用连接。

标签: openssl ssl-certificate x509certificate


【解决方案1】:

OpenSSL 的 s_client 永远不会终止错误的证书,除非您也使用
-verify_return_error 参数(正如 @bartonjs 在 cmets 中所建议的那样)问他。

您可以在手册页 man 1 s_clientonline 中阅读更多相关信息。在 NOTES 中查找 -verify 参数或更高版本:

如果验证服务器证书时出现问题,则-showcerts 选项可用于显示服务器发送的所有证书。

s_client 实用程序是一个测试工具,旨在继续握手 在任何证书验证错误之后。因此,它将接受任何 对等方发送的证书链(可信与否)。无测试应用 不应该这样做,因为这会使他们容易受到 MITM 攻击。这 可以使用 -verify_return_error 选项更改行为:任何验证 然后返回错误以中止握手。

如果您看到的结果是您看到的最后一个“错误”,则可能是服务器上的其他东西正在终止连接。您应该在 Web 服务器日志中看到原因。

【讨论】:

  • 我相信问题的提交者甚至不想在输出中看到:**Verify return code: 21 (unable to verify the first certificate)**
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-06
  • 2020-10-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多