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

cas*_*sen 10 ssl curl ssl-certificate docker tls1.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.
Run Code Online (Sandbox Code Playgroud)

经过一番挖掘,我现在知道这个问题也出现在我的 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 的引擎

Luk*_*ner 22

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

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

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

将证书导出为 DER 编码 x.509 并将其保存在“D:\eset.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
Run Code Online (Sandbox Code Playgroud)

  • 谢谢你!就我而言,我们使用 Zscaller(防火墙),因此我需要复制“Zscaler Root CA”证书 (4认同)
  • 我的公司也在使用 Zscaler,我尝试了上述步骤,导出我的 zscaler 根证书并复制到上面的 ca-certificates 文件夹,然后运行“update-ca-certificates”。但我仍然面临这个问题,有人可以帮助我吗?错误 - (由 SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1131)' 引起)' (2认同)