在來源伺服器 x.509 上使用curl時出現奇怪的TLS錯誤

在來源伺服器 x.509 上使用curl時出現奇怪的TLS錯誤

我希望有人可以幫助解釋這種情況下發生了什麼。

截至目前,我有一個來自 google 網域的網域,並且使用 cloudflare 進行 DNS 管理。我沒有使用 cloudflare 的任何 TLS/SSL 功能,通用 SSL 已關閉,也沒有代理我的 DNS 請求。我使用 caddy 作為伺服器上的反向代理,並使用內建的 acme 用戶端從 LetsEncrypt 取得憑證。我得到的證書很好,我的外部網站都顯示正在使用的證書,這是位於我的伺服器上的證書。然而,當我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時,我覺得我的路由器出了問題。因為那是我的路由器管理登入頁面的路徑。

相關內容