有没有一种命令可以检查主机网站所需的TLS版本?目前,我唯一知道的检查方法是调整浏览器的最大TLS版本,并检查是否仍然能够访问该站点。但我怀疑是否有更高级的方法。
您可以使用以下命令进行检查。
对于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版本。如果您没有看到证书链,并出现类似于“握手错误”的内容,则不支持。
-tls1_3
- undefined来源于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版本支持,还能为每个版本检查密码支持,并提供评分。
我喜欢使用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
Nmap有非常方便的TLS版本和密码套件检查NSE脚本。这一切都是多平台的:https://nmap.org/nsedoc/scripts/ssl-enum-ciphers.html
-p
(--protocols
)标志仅测试支持的TLS版本。testssl.sh
,我可以通过其IP地址测试单个服务器。./testssl.sh -p --ip 123.123.123.123 https://example.com