【问题标题】:curl by default should use tls1.2 not tls1.3curl 默认应该使用 tls1.2 而不是 tls1.3
【发布时间】:2021-11-19 08:29:01
【问题描述】:

我有一个 https 服务端点,它公开 prometheus 之类的指标,仅适用于 tls1.2

curl -v --tlsv1.2 --tls-max 1.2 --key keys/client.key --cert certs/client.crt  https://172.99.197.118:5000/metrics -k

现在我尝试使用 curl 命令而不指定任何 tls 版本,但默认情况下 curl 使用 tls1.3。有什么方法可以配置 curl 或 openssl 包以默认使用 tls1.2。

$ curl -v --key keys/client.key --cert certs/client.crt  https://172.99.197.118:5000/metrics -k
*   Trying 172.99.197.118:5000...
* TCP_NODELAY set
* Connected to 172.99.197.118 (172.99.197.118) port 5000 (#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.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Request CERT (13):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Certificate (11):
* TLSv1.3 (OUT), TLS handshake, CERT verify (15):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=New York; L=Armonk; OU=Cloud; CN=pod.cluster.local
*  start date: Jan 21 16:35:29 2021 GMT
*  expire date: Jan 21 16:35:59 2022 GMT
*  issuer: CN=Operator Vault Intermediary CA
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x56483c873e10)
> GET /metrics HTTP/2
> Host: 172.99.197.118:5000
> user-agent: curl/7.68.0
> accept: */*
>
* TLSv1.3 (OUT), TLS alert, illegal parameter (559):
* OpenSSL SSL_read: error:14160098:SSL routines:read_state_machine:excessive message size, errno 0
* Failed receiving HTTP2 data
* OpenSSL SSL_write: SSL_ERROR_SYSCALL, errno 0
* Failed sending HTTP2 data
* Connection #0 to host 172.99.197.118 left intact
curl: (56) OpenSSL SSL_read: error:14160098:SSL routines:read_state_machine:excessive message size, errno 0

【问题讨论】:

  • 您可以将--tlsv1.2 放入.curlrc 文件中。
  • 它工作正常。谢谢
  • 想知道这是http2问题而不是tls1.3问题,如果您使用--http1.1,问题是否仍然存在?

标签: curl openssl tls1.2


【解决方案1】:

可以通过将以下行添加到您的 ~/.curlrc 来更改 TLS 版本

https://everything.curl.dev/usingcurl/tls#ssl-and-tls-versions

在这种情况下,您要查找的选项是 --tlsv1.2

【讨论】:

    【解决方案2】:

    如果它仅支持 TLS1_2,则双方不会就 TLS1_3 达成一致,如客户端和服务器 hello 消息中所示。

    您遇到的错误可能是由于服务器尝试验证客户端证书而发生的。如果确实如此,您应该检查它失败的原因。会不会是服务器不信任的自签名证书?

    【讨论】:

      猜你喜欢
      • 2023-02-19
      • 2018-05-21
      • 1970-01-01
      • 2017-02-10
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 2019-03-26
      • 2015-09-28
      相关资源
      最近更新 更多