curl: (35) 错误:1407742E:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1 警报协议(protocol)版本

标签 curl

我正在尝试使用 curl ,但遇到以下问题:

# curl -v --cacert ./ca.crt --key ./private/X.key --cert ./issued/X.crt https://X.X.X
* Rebuilt URL to: https://X.X.X/
*   Trying X.X.X.X...
* TCP_NODELAY set
* Connected to X.X.X (X.X.X.X) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: ./ca.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Unknown (21):
* TLSv1.2 (IN), TLS alert, Server hello (2):
* error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
* Curl_http_done: called premature == 1
* stopped the pause stream!
* Closing connection 0
curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
# 
# curl --version
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2s zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL 
# 

请指教。

最佳答案

我还尝试从另一个环境运行相同的 curl 命令(结果相同):

# curl --version
curl 7.38.0 (x86_64-pc-linux-gnu) libcurl/7.38.0 OpenSSL/1.0.1t zlib/1.2.8 libidn/1.29 libssh2/1.4.3 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API SPNEGO NTLM NTLM_WB SSL libz TLS-SRP 
# cat /etc/debian_version 
8.11
# 

但在另一个环境中运行没有任何问题:
$ curl --version
curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1c zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Release-Date: 2019-02-06
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL 
$ cat /etc/debian_version 
kali-rolling
$ 

所有环境都使用可用于操作系统的最新(最新)版本的 curl/openssl 包。

我相信它与旧版本的 curl 和/或 openssl 不支持最新的 tlsv1.3 有关,因为工作环境有:
$ curl --help | grep -- --tlsv1.3
     --tlsv1.3       Use TLSv1.3 or greater
$ 

关于curl: (35) 错误:1407742E:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1 警报协议(protocol)版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56974294/

相关文章:

php - 使用 guzzle 在 vagrant 上 curl 错误 7

php - 使用 PHP 中的 webhook 将文件上传到 Discord

AWS Lambda 上的 cURL 给出了未找到命令的错误

c# - 在 .Net Core 3.1 中使用重定向和 Cookie 复制 cURL 命令

curl - Paypal 沙箱异常 "Unable to communicate with the PayPal gateway"Magento

PHP file_get_contents/curl - 得到与浏览器不同的结果

从 docker 容器到主机超时的 curl 请求

php - curl: (35) 连接到的未知 SSL 协议(protocol)错误 - 调用 web 服务时出错

c++ - 数据被添加到 curl 的检索内容中

c++ - Visual C++ 窗体应用程序错误 : C3374