我正在尝试发送一个简单的curl请求:
curl -k -i --key ./key.pem --cert ./cert.pem https://target_ip/whatever/
我遇到的问题是它没有发送任何证书。验证明显通过,否则我会看到诸如密钥不匹配等错误,但我可以在wireshark中看到证书未在TCP连接(围绕Client Hello)中被发送。像
--verbose
或--cacert
这样的开关也没有什么用处。我能够通过postman成功地发送完全相同的证书。
我尝试从不同的来源发送相同的curl请求,例如我的WSL2 ubuntu、云中的debian容器、虚拟机等等。
有什么提示为什么它不发送证书吗?
编辑I - curl -v 的输出
* Trying 52.xxx.xxx.xx:443...
* TCP_NODELAY set
* Connected to 52.xxx.xxx.xx (52.xxx.xxx.xx) 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:
* subject: CN=NGINXIngressController
* start date: Aug 10 18:08:13 2020 GMT
* expire date: Aug 10 18:08:13 2021 GMT
* issuer: CN=NGINXIngressController
* SSL certificate verify result: self signed certificate (18), continuing anyway.
> GET /whatever/ HTTP/1.1
> Host: custom.localhost.dev
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: Bearer eyJ0...
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden
< Server: nginx/1.19.0
Server: nginx/1.19.0
< Date: Mon, 10 Aug 2020 22:23:24 GMT
Date: Mon, 10 Aug 2020 22:23:24 GMT
< Content-Type: text/html
Content-Type: text/html
< Content-Length: 153
Content-Length: 153
< Connection: keep-alive
Connection: keep-alive
<
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.19.0</center>
</body>
</html>
* Connection #0 to host 52.xxx.xxx.xx left intact
编辑二 - wireshark 抓包
匿名化 pcap 过于繁琐,这里只提供一些截图,请您查看所需内容。我已经在数据包中标出了没有看到证书发送的位置。请注意,我在我的 Windows 工作站上运行 postman,而 curl 在 WSL2 上运行,因此源地址有所不同。但其他 curl 主机的行为也是相同的。
Curl
Postman
编辑三 - 客户端 Hello 信息
Curl
Postman
CertificateRequest
)?URL是否与Postman完全相同?您能提供curl -v
的调试输出吗? - Steffen Ullrich