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

irtuqstp  于 2022-11-13  发布在  Docker
关注(0)|答案(1)|浏览(186)

在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发布的操作系统。显然这可能是错误的来源,但他们无法帮助我调试这个问题。然而,一个同事的PC,它工作得完美无缺。
有什么想法吗?

PC设置:

  • Windows 10企业版
  • 版本:21 H1
  • 操作系统内部版本:19043.1645
  • Windows功能体验包:120.2212.4170.0
  • 使用Ubuntu的WSL 2 -20.04
  • Docker桌面4.7.1(77678),带有基于WSL 2的引擎
cx6n0qe3

cx6n0qe31#

我在我的公司也遇到过类似的问题。问题是我们的防火墙替换了证书。防火墙的证书在我的wsl设置中是不可信的/未知的。
我通过从windows certmanager(certmgr.msc)中导出防火墙证书来解决这个问题。
证书位于“受信任的根证书颁发机构\证书”
将证书导出为编码为x.509的DER,并将其保存在“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

相关问题