在原始服务器 x.509 上使用 curl 时出现奇怪的 TLS 错误

在原始服务器 x.509 上使用 curl 时出现奇怪的 TLS 错误

我希望有人能帮忙解释一下这种情况发生了什么。

到目前为止,我有一个来自 google domains 的域名,并且我正在使用 cloudflare 进行 DNS 管理。我没有使用 cloudflare 的任何 TLS/SSL 功能,通用 SSL 已关闭,并且也没有代理我的 DNS 请求。我在服务器上使用 caddy 作为反向代理,并且我正在使用从 letsencrypt 获取证书的内置 acme 客户端。我可以正常获取证书,并且我的外部站点都显示正在使用的证书,即位于我服务器上的证书。但是,当我curl通过 HTTPS 在我的服务器上运行命令时,我得到了这种奇怪的行为:

为了进一步解释,我正在尝试向我的 gotify 服务器/实例发送一个 curl 请求。这是我使用 gotify cli 命令时的输出,gotify init然后我使用 https:// 输入我的域名并收到此输出(这发生在我的所有域名上(当我在 gotify 命令之后运行下面的基本 curl 命令时),但仅使用 gotify cli 作为错误来源的示例):

x509: certificate is not valid for any names, but wanted to match gotify.mydomain.com

因此,我运行这些 curl 命令来弄清楚发生了什么。

命令:curl -v https://gotify.mydomain.com 输出:

* 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 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: self signed certificate
* Closing connection 0
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

我的 CApath 确实拥有来自 ca-certificates 包的所有证书。我的外部网站正在使用我的证书,但我的服务器有问题,我不知道原因。

当我运行此命令时,curl -v --insecure https://gotify.mydomain.com我得到了更奇怪的结果:输出:

* 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-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=CN; ST=TW; L=TB; O=ASKEY; OU=ROUTER; CN=askey.com; [email protected]
*  start date: Jan  8 18:43:23 2022 GMT
*  expire date: Jan  7 18:43:23 2025 GMT
*  issuer: C=CN; ST=TW; L=TB; O=ASKEY; OU=ROUTER; CN=askey.com; [email protected]
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
> GET / HTTP/1.1
> Host: gotify.mydomain.com
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Location: /1.2.4/login.html
< Content-Length: 0
< Date: Sun, 24 Apr 2022 13:51:04 GMT
< Server: lighttpd/1.4.38
<
* Connection #0 to host gotify.mydomain.com left intact

完全不知道这个“askey”证书是从哪里来的。据我所知,它根本不在我的服务器上。我完全糊涂了。我位于台湾,所以 TW 代码可能有点道理。1 月 8 日我甚至无法远程访问我的服务器,所以我不知道发生了什么。

看到这个后,Location: /1.2.4/login.html我以为我的路由器出了问题。因为这是我的路由器管理员登录页面的路径。

相关内容