컬이 지원하는 TLS 버전 확인

컬이 지원하는 TLS 버전 확인

curlPATH의 실행 파일이 최신 버전을 지원 tlsv1.0하는지 Bash 스크립트에서 확인하는 방법은 무엇입니까 ?tlsv1.1

기본적으로 TLS v1.2가 지원되지 않는 경우 사용자에게 알리고 curl필요한 조치를 취하고 싶습니다. 나는 들어갈 것이다임베디드 시스템Busybox와 맞춤형 Linux 환경(특히 NAS)이 있으므로 Linux 배포판에 의존할 수 없습니다.

다음은 두 가지 예입니다(시스템 1그리고시스템 2); 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

답변1

노력하다:

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"
fi

관련 정보