WSL-Docker:curl:(60) SSL 证书问题:无法获取本地颁发者证书

问题描述 投票:0回答:2

PC 重新配置后,我无法正确使用 Docker,因为某些curl 命令由于 SSL/TLS 问题而被拒绝。

仅在一个示例中

curl -vfsSL https://apt.releases.hashicorp.com/gpg
返回以下错误:

*   Trying 52.222.214.125:443...
* TCP_NODELAY set
* Connected to apt.releases.hashicorp.com (52.222.214.125) 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.3 (OUT), TLS change cipher, Change cipher spec (1):
* 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, Certificate (11):
* TLSv1.3 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.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.

经过一番挖掘,我现在知道这个 问题也出现在我的 WSL 映像中,但不会出现在主机 Windows 操作系统上。因此,我相信这一定是由我的 WSL 设置引起的问题,而不是由 Docker 本身引起的(?)。

StackOverflow 上有很多相关问题,但我发现没有真正适用于这种情况的解决方案(并且它不是禁用验证的选项,这通常是建议的解决方案):

FWIW 我在一家企业工作,使用 IT 发布的操作系统。显然这可能是错误的根源,但他们无法帮助我调试这个问题。然而,在一位同事的电脑上,它运行得非常完美。

有什么想法吗?


电脑设置:

  • Windows 10 企业版
    • 版本:21H1
    • 操作系统版本:19043.1645
    • Windows 功能体验包:120.2212.4170.0
  • WSL 2 与 Ubuntu-20.04
  • Docker Desktop 4.7.1 (77678),带有基于 WSL 2 的引擎
docker ssl curl ssl-certificate tls1.2
2个回答
17
投票

我的公司也遇到了类似的问题。 问题是我们的防火墙替换了证书。 在我的 wsl 设置中,防火墙的证书不受信任/未知。

我通过从 Windows certmanager (certmgr.msc) 导出防火墙证书解决了该问题。

证书位于“受信任的根证书颁发机构\证书”

将证书导出为 DER 编码 x.509 并将其保存在 例如“D:设置.cer”。

在 WSL 中,您可以使用以下命令添加证书:

openssl x509 -inform DER -in /mnt/d/eset.cer -out ./eset.crt
sudo cp eset.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates

0
投票

我按照以下命令将 Zscaler 根 CA 导出到 WSL2,包括我们的企业根 CA:

openssl x509 -inform DER -in zscaler-root-ca.cer -out ./zscaler-root-ca.crt
sudo cp zscaler-root-ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates

但是,我收到以下 403 Forbidden 错误:

wget https://github.com/ahmetb/kubectx/archive/v0.9.5.tar.gz

--2023-11-25 02:06:44-- https://github.com/ahmetb/kubectx/archive/v0.9.5.tar.gz 正在解析 github.com (github.com)...140.82.121.3 正在连接 github.com (github.com)|140.82.121.3|:443...已连接。 HTTP 请求已发送,正在等待响应... 302 发现 位置:https://codeload.github.com/ahmetb/kubectx/tar.gz/refs/tags/v0.9.5[以下] --2023-11-25 02:06:44-- https://codeload.github.com/ahmetb/kubectx/tar.gz/refs/tags/v0.9.5 正在解析 codeload.github.com (codeload.github.com)...140.82.121.9 正在连接到 codeload.github.com (codeload.github.com)|140.82.121.9|:443...已连接。 HTTP 请求已发送,正在等待响应... 307 临时重定向 位置:https://gateway.zscloud.net:443/_sm_ccik?_ordtok=WmW3WV555bkVs64Jf4DHqTnvpQ&_sm_rid=NQfRp5j05PV7HPD0MTHHnqZnV6tk6rp5J15jrqqtk6rp5J15jrqq&_orig_url=https://codeload.github。 com/ahmetb/kubectx/tar.gz/refs/tags/v0.9.5 [下列的] --2023-11-25 02:06:45-- https://gateway.zscloud.net/_sm_ccik?_ordtok=WmW3WV555bkVs64Jf4DHqTnvpQ&_sm_rid=NQfRp5j05PV7HPD0MTHHnqZnV6tk6rp5J15jrqqtk6rp5J15j rqq&_orig_url=https://codeload.github.com/ahmetb/kubectx/tar.gz /refs/tags/v0.9.5 正在解析 gateway.zscloud.net (gateway.zscloud.net)... 165.225.16.238 正在连接 gateway.zscloud.net (gateway.zscloud.net)|165.225.16.238|:443...已连接。 HTTP 请求已发送,正在等待响应... 307 临时重定向 位置:https://codeload.github.com/ahmetb/kubectx/tar.gz/refs/tags/v0.9.5?_sm_nck=1[以下] --2023-11-25 02:06:45-- https://codeload.github.com/ahmetb/kubectx/tar.gz/refs/tags/v0.9.5?_sm_nck=1 正在连接到 codeload.github.com (codeload.github.com)|140.82.121.9|:443...已连接。 HTTP 请求已发送,正在等待响应... 403 Forbidden 2023-11-25 02:06:46 错误 403:禁止。

© www.soinside.com 2019 - 2024. All rights reserved.