如何从Bash脚本中检查路径中的curl可执行文件是否支持tlsv1.0或tlsv1.1或更新版本?
基本上,我想通知用户,如果它的curl不支持TLSV1.2,并采取必要的操作。我将在具有Busybox和自定义Linux环境(特别是NAS )的嵌入式系统中运行脚本,因此不能依赖Linux发行版。
下面有两个示例(system1和system2);我可以为命令行交换机提供grep,但这是一个好的实践吗?
[system1:~] # curl --version
curl 7.21.0 (i686-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8e zlib/1.2.3.3 libidn/1.0
Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
[system1:~] # curl --help all | grep -- --tlsv
-1/--tlsv1 Use TLSv1 (SSL)
[system2:~] # curl --version
curl 7.76.0 (x86_64-openwrt-linux-gnu) libcurl/7.76.0 OpenSSL/1.1.1h zlib/1.2.11
Release-Date: 2021-03-31
Protocols: file ftp ftps http https imap imaps mqtt pop3 pop3s rtsp smtp smtps tftp
Features: alt-svc HTTPS-proxy IPv6 Largefile libz SSL
[system2:~] # curl --help all | grep -- --tlsv
-1, --tlsv1 Use TLSv1.0 or greater
--tlsv1.0 Use TLSv1.0 or greater
--tlsv1.1 Use TLSv1.1 or greater
--tlsv1.2 Use TLSv1.2 or greater
--tlsv1.3 Use TLSv1.3 or greater发布于 2021-10-11 18:56:38
尝试:
curl --tlsv1.2 --silent --connect-timeout 1 --url 'http://localhost:1' 2>/dev/null
if [[ $? -eq 2 ]]; then # 2 == CURLE_FAILED_INIT
echo "TLS 1.2 protocol not supported by this cURL version"
fihttps://unix.stackexchange.com/questions/672792
复制相似问题