gpt4 book ai didi

docker - 如何修复 "SSL certificate problem: self signed certificate in certificate chain"错误?

转载 作者:太空宇宙 更新时间:2023-11-03 12:47:41 26 4
gpt4 key购买 nike

我有一个基于 Linux 的 Docker 容器,如果我这样做:

curl https://google.com

...然后我得到一个错误:

curl: (60) SSL certificate problem: self signed certificate in certificate chain More details here: https://curl.haxx.se/docs/sslcerts.html

任何 URL 都会发生同样的情况 - 错不在 Google。

上面引用的链接提供了各种解决方案,除了最后一个建议更新证书存储的解决方案外,其他似乎都不合适。但是没有关于如何执行此操作的说明(或者至少没有对我有意义的说明)。

这是正确的做法吗?如果正确的话如何做?


更新:根据要求,结果如下:

openssl s_client -showcerts -connect www.google.com:443

CONNECTED(00000003)
depth=3 DC = com, DC = forestroot, CN = SHA256RootCA
verify error:num=19:self signed certificate in certificate chain
---
Certificate chain
0 s:/C=US/ST=California/L=Mountain View/O=Google LLC/CN=www.google.com
i:/CN=ssl-decrypt
-----BEGIN CERTIFICATE-----
MIIDXzCCAkegAwIBAgIIXIk3p8xOX/kwDQYJKoZIhvcNAQELBQAwFjEUMBIGA1UE
AxMLc3NsLWRlY3J5cHQwHhcNMTgxMjE5MDgxNzAwWhcNMTkwMzEzMDgxNzAwWjBo
...
tq0VAGIoj4+YhO6bktTq3alCRoLstJuuxjVdb1wRkH4YRi0I6ZAB1Cw+M8Lg+2eQ
KuEo
-----END CERTIFICATE-----
1 s:/CN=ssl-decrypt
i:/DC=com/DC=bgs/CN=SHA256IssueCA
-----BEGIN CERTIFICATE-----
MIIGzDCCBLSgAwIBAgITEQAADvB9T7mSaacwDQABAAAO8DANBgkqhkiG9w0BAQsF
ADBCMRMwEQYKCZImiZPyLGQBGRYDY29tMRMwEQYKCZImiZPyLGQBGRYDYmdzMRYw
...
1z9f/nkj2XTRyGeACoy0qRd5uXJHp1iGM27l3RFDR9OjrfPV56pOBUYWAlc9Nn+1
Vr3qUZrcCkROrmYisVF4jg==
-----END CERTIFICATE-----
2 s:/DC=com/DC=MyCompanyServer/CN=SHA256IssueCA
i:/DC=com/DC=MyCompanyServer/CN=SHA256RootCA
-----BEGIN CERTIFICATE-----
MIIH4zCCBcugAwIBAgITOQAAAAOa4wv9nnK0uQAAAAAAAzANBgkqhkiG9w0BAQsF
ADBIMRMwEQYKCZImiZPyLGQBGRYDY29tMRowGAYKCZImiZPyLGQBGRYKZm9yZXN0
...
IomErcbcymIWBmN75PVMsk9EMyqDP394jG8+IOK+lVUVX4pxzhdd7eYbqTAwDE1X
bNWcZZkt/w==
-----END CERTIFICATE-----
3 s:/DC=com/DC=MyCompanyServer/CN=SHA256RootCA
i:/DC=com/DC=MyCompanyServer/CN=SHA256RootCA
-----BEGIN CERTIFICATE-----
MIIFgzCCA2ugAwIBAgIQULxmYXGJ1aFIlIyCHA4NIzANBgkqhkiG9w0BAQsFADBI
MRMwEQYKCZImiZPyLGQBGRYDY29tMRowGAYKCZImiZPyLGQBGRYKZm9yZXN0cm9v
...
jQBLY0/KIjHywv66GhtVWpexgQcXrLxQP2VHW7eXpsylvwkNU5XNQYzHTB7u+w5C
VunfRLt/7mVWyURcwkOre38tVSByKR4=
-----END CERTIFICATE-----
---
Server certificate
subject=/C=US/ST=California/L=Mountain View/O=Google LLC/CN=www.google.com
issuer=/CN=ssl-decrypt
---
No client certificate CA names sent
Peer signing digest: SHA256
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 6556 bytes and written 302 bytes
Verification error: self signed certificate in certificate chain
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES128-GCM-SHA256
Session-ID: 723D9976F985887CA5F256EE3C2E7B44B9C98A6B440AAF4E19564AE101F78D00
Session-ID-ctx:
Master-Key: C3D8759A753C1D269FF9C00854E59B8C10ABC1E94AFE9F0166486A649FE295ACE1AF5E5BEDB0129E557E781BC860D2FA
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1548690163
Timeout : 7200 (sec)
Verify return code: 19 (self signed certificate in certificate chain)
Extended master secret: yes
---
read:errno=0

我从中收集到的信息是,该链中有属于我工作的公司(我已将其重命名为 MyCompanyServer)的证书,我想这就是问题所在。

我是否认为我需要为该证书安装某种 key ?这对我来说都是希腊语,所以对于新手问题深表歉意。

最佳答案

可能您在容器中没有可用的正确 CA 证书,因此无法验证 TLS 连接。

尝试安装 ca-certificates 包(包可能有不同的名称,这取决于使用的发行版)。


更新:

您的公司检查公司网络中的 TLS 连接,因此原始证书将替换为您的公司证书。您需要将公司 CA 证书添加到根 CA 证书。

Linux(Ubuntu、Debian):

  • 将公司CA证书复制到目录/usr/local/share/ca-certificates/
  • 运行 sudo update-ca-certificates

如果您的主机操作系统已经正确预配置了 CA 证书(包括公司 CA 证书),那么您可以将它们作为一个卷安装到容器中:

docker run \
-v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt \
...

典型的 CA 证书位置:

  • /etc/ssl/certs/ca-certificates.crt Debian/Ubuntu/Gentoo 等
  • /etc/pki/tls/certs/ca-bundle.crt Fedora/RHEL 6
  • /etc/ssl/ca-bundle.pem OpenSUSE
  • /etc/pki/tls/cacert.pem OpenELEC
  • /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem CentOS/RHEL 7

关于docker - 如何修复 "SSL certificate problem: self signed certificate in certificate chain"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54402673/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com