【发布时间】:2021-10-11 06:36:49
【问题描述】:
当我使用这个命令拉取代码时:
➜ rt-analysis-multibranch_zhuolian git:(zhuolian) git pull
fatal: unable to access 'https://gitlab.example.com/development/soa-report-analysis.git/': SSL certificate problem: certificate has expired
我确定证书没有过期,因为在其他 macOS PC 上我可以从同一个 url 中提取代码。服务器端证书由 Let's Encrypt 生成。 macOS Catalina openssl 版本为:
➜ ~ openssl version
LibreSSL 2.6.5
我尝试使用 curl,错误如下:
➜ rt-analysis-multibranch_zhuolian git:(zhuolian) curl https://gitlab.example.com/development/soa-report-analysis.git
curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure.
为什么会这样?我应该怎么做才能解决它?我可以使用相同的 url 从 Google Chrome 浏览器访问 repo。
我最后发现我上次更新 let's encrypt 证书时默认使用 ISRG Root X1 根证书。 ISRG Root X1 仅与 macOS 10.12.1 兼容。但是为什么 curl 命令似乎验证了旧证书。为什么会这样?
【问题讨论】:
-
实际服务器(不是 example.com)是否使用带有 LE 的“兼容性”链的 LetsEncrypt 证书?你的 curl 和 git 是否使用低于 3.2.7 或 3.3.5 的 OpenSSL 1.0.2 或 LibreSSL(我认为后者更可能在 Mac 上)并且他们是否使用包含 DST X3 根证书的 CA 文件(又名包) (除了 ISRG X1 根证书)?如果是这样,那是您的问题,您需要更改服务器的证书链(如果您控制它),使用新的(er)SSL 库更新到软件,或者更新或修改 CA 文件?
-
我粘贴了所有我知道的版本信息,我不确定服务器端证书是否是 LE 的“兼容性”链。 @dave_thompson_085 我应该如何处理我的服务器端证书?
-
如果您执行或知道证书颁发:如果使用
certbot而不指定特定链,则默认为“兼容性”链,因为 LE 认为这是个好主意。对于 certbot 以外的任何内容,您都必须提供详细信息。如果您不知道发行,但服务器正在使用 PEM 格式文件,请查看它们的内容,它们可能已经识别了主题和发行者,否则将每个 PEM 块放在单独的文件中并执行openssl x509 -in <onecert -noout -subject -issuer.如果它们采用其他格式,您需要提供详细信息。 ... -
... 如果您无权访问服务器文件或无法解码它们,请执行
openssl s_client -connect theserver:443 -servername theserver -showcerts </dev/null并捕获输出;它将包含几个 PEM 块。将彼此放在一个单独的文件中,然后像上面一样继续。在任何一种情况下,如果最后一个证书(PEM 块)的颁发者带有CN=DST Root CA X3,那就是兼容性链。要更改它,如果使用 certbot,您可以使用--preferred-chain 'ISRG Root X1'进行更新。否则,根据文件格式,您可以编辑它们;详细说明。 ... -
... 或者,正如我所说,您可以从 client 信任库中删除 DST。运行
curl -v any_https_url将显示它正在使用的 CA 文件;你可以修改它,或者如果它是一个系统文件,你不能或不想修改,复制它,修改副本,然后使用curl --cacert your_fixed_file。但是,我不知道git是否与curl使用相同,因此您可能需要更多来解决您的实际问题。
标签: https