ssl 检查主机所需TLS版本的命令提示符

eivnm1vs  于 2022-11-14  发布在  其他
关注(0)|答案(5)|浏览(115)

有没有一个命令可以检查主机站点所需的TLS版本?目前,我知道的唯一检查方法是调整浏览器的最大TLS版本,然后检查我是否还能访问该站点。不过,我怀疑有一个更复杂的方法可以做到这一点。

dbf7pr2w

dbf7pr2w1#

可以使用以下命令进行检查。
对于TLS 1.2:

openssl s_client -connect www.google.com:443 -tls1_2

对于TLS 1.1:

openssl s_client -connect www.google.com:443 -tls1_1

对于TLS 1:

openssl s_client -connect www.google.com:443 -tls1

如果你得到证书链和握手,那么TLS版本是受支持的。如果你没有看到证书链,和类似于“握手错误”的东西,那么它不是。

fnx2tebb

fnx2tebb2#

https://maxchadwick.xyz/blog/checking-ssl-tls-version-support-of-remote-host-from-command-line开始:

nmap ssl-enum-ciphers

检查SSL / TLS版本支持的另一个选项是nmap。nmap通常在默认情况下不安装,因此您需要手动安装它。安装后,您可以使用以下命令检查SSL / TLS版本支持...

nmap --script ssl-enum-ciphers -p 443 www.google.com

nmap的ssl-enum-ciphers脚本不仅会一次检查所有版本(TLS 1.0、TLS 1.1和TLS 1.2)的SSL / TLS版本支持,而且还会检查每个版本的密码支持,包括提供评分。

dkqlctbz

dkqlctbz3#

看来最老练的办法是对每个版本都这样检查:
openssl s_客户端-连接:-

nzk0hqpo

nzk0hqpo4#

Nmap有非常方便的TLS版本和密码套件检查NSE脚本。所有在一个,多平台:https://nmap.org/nsedoc/scripts/ssl-enum-ciphers.html

yxyvkwin

yxyvkwin5#

我喜欢使用curl,它可以很好地报告TLS版本协商。
例如,这会尝试使用TLS 1.1进行连接,服务器会协商将其升级到1.2:

$ curl -Iiv --tlsv1.1 https://example.com
*   Trying 192.168.205.11:443...
* TCP_NODELAY set
* Connected to example.com (192.168.205.11) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
[...]

要禁止服务器升级TLS版本,请使用--tls-max选项:

$ curl -Iiv --tlsv1.1 --tls-max 1.1 https://example.com
*   Trying 192.168.205.11:443...
* TCP_NODELAY set
* Connected to example.com (192.168.205.11) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS alert, internal error (592):
* error:141E70BF:SSL routines:tls_construct_client_hello:no protocols available
* Closing connection 0
curl: (35) error:141E70BF:SSL routines:tls_construct_client_hello:no protocols available

在这种情况下,连接会失败,因为客户端不提供任何高于1.1的TLS版本,但服务器不接受任何低于1.2的版本。如果这样使用,输出与openssl_client输出非常相似。

相关问题