docker - WSL-Docker : curl: (60) SSL certificate problem: unable to get local issuer certificate

标签 docker ssl curl ssl-certificate 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.

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

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

FWIW 我在一家企业工作,使用 IT 发行的操作系统。显然这可能是错误的来源,但他们无法帮助我调试此问题。然而,一位同事的 PC 运行完美。

有什么想法吗?


PC 设置:

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

最佳答案

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

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

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

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

enter image description here

在您的 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

关于docker - WSL-Docker : curl: (60) SSL certificate problem: unable to get local issuer certificate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72167566/

相关文章:

php - 使用 goutte 进行同步 HTTP 请求

maven - 不要在 Docker 构建中下载所有 Maven 依赖项

heroku - 在同一个 Docker Hub 存储库中链式自动构建

docker error :/var/run/docker. sock: 没有这样的文件或目录

apache - 配置 Apache TLS 1.2

.htaccess - htaccess/mod_rewrite/SSL |如果 : http off and (basket or order), 301 https,否则 301 http

web-services - Camel cxf webservice - 获取响应的问题

ruby-on-rails - 仅将 JSON curl 请求的值保存到 RoR 中的 PG 数据库

php - 如何授予对PaaS(Symfony CLoud)目录的访问权限?

php - cURL 和重定向 - 返回多个 header ?