apt-get update 失败,因为 nodesource 上的握手失败导致证书验证失败

apt-get update 失败,因为 nodesource 上的握手失败导致证书验证失败

sudo apt-get update在我的 AWS EC2 Ubuntu 18.04.01 LTS 实例上运行失败:

Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown

当尝试访问deb.nodesource.com/node_10.x bionic 发布

运行后结果如下sudo apt-get update

Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Ign:3 https://deb.nodesource.com/node_10.x bionic InRelease
Get:4 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Err:5 https://deb.nodesource.com/node_10.x bionic Release
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: XX.XXX.XX.XX 443]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Reading package lists... Done
W: https://deb.nodesource.com/node_10.x/dists/bionic/InRelease: No system certificates available. Try installing ca-certificates.
W: https://deb.nodesource.com/node_10.x/dists/bionic/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://deb.nodesource.com/node_10.x bionic Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

看来我当前安装的 Node.js 导致了这个问题。

我尝试过ca-certificates在 中安装和更新etc/ssl/certs,但是这没有帮助。我不太清楚如何从这里开始解决这个问题。

我并不是在寻找一种会危及服务器安全的快速解决方法。

答案1

我在尝试将 mongodb-org 4.0 的密钥添加到运行 Ubuntu 18.04 的 docker 容器时遇到了此错误。此基础映像中安装的证书存在问题。我设法通过安装修复了它ca-certificates

sudo apt install ca-certificates

答案2

对于那些仍然遇到此问题的人,这是我从Ubuntu 手册页

OP的帖子表明证书验证错误:

Err:5 https://deb.nodesource.com/node_10.x bionic Release
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: XX.XXX.XX.XX 443]

我在位于公司代理后面的虚拟机上遇到了类似的问题。代理充当中间人,在流量流经代理时对其进行解密和重新加密。即使我在虚拟机上为代理安装了受信任的证书,此错误仍然发生,这是由无效的 OCSP 响应引起的。为了修复它,我运行了以下命令:

touch /etc/apt/apt.conf.d/99verify-peer.conf \
&& echo >>/etc/apt/apt.conf.d/99verify-peer.conf "Acquire { https::Verify-Peer false }"

这会禁用 apt 的 OCSP 验证,不推荐使用。

我选择了另一种解决方案,其他人可能没有这个方案。我们公司为此类用例维护了一个非解密代理,所以我改用它。

答案3

您可以[trusted=yes]在 中添加sources.list。例如:

deb [trusted=yes] http://ppa.launchpad.net/repo_name/pkg/ubuntu vivid main
deb-src [trusted=yes] http://ppa.launchpad.net/repo_name/pkg/ubuntu vivid main

答案4

今天,我在一个旧的、维护不善的 Ubuntu 16 版本上遇到了这个问题。

第一个问题是 /etc/apt 中的源是 HTTP 而不是 HTTPS,并且它们已被阻止。HTTPS 链接验证失败,这是意料之中的,因为我相信他们使用 LetsEncrypt,并且去年 10 月他们更改了认证路径。

但我无法更新,ca-certificates因为它们被认为是最新的——而且我无法让 apt 理解它们不是因为您知道,更新没有起作用。

所以:

  1. 通过添加暂时禁用证书验证

    Acquire { https::Verify-Peer false }
    

    /etc/apt/apt.conf.d/99verify-peer.conf

  2. 运行apt update以获取新的 ca 证书信息

  3. 跑步apt install ca-certificates

  4. 重新启用证书验证

    编辑上述文件并删除对等验证绕过。如果文件现在为空,您可以将其删除。

现在一切都应该大多工作。

然后我继续清理 apt 缓存,并运行完整的 dist-upgrade。这反过来解锁了命令do-release-upgrade。第一次运行的时候它没有完全起作用,我不得不apt-get update再次运行,清理不需要的包并删除两个有冲突的包,然后更新。

经过几个小时,又从 18 版升级了一次,我的系统运行的是 Ubuntu 20.04-LTS,并且可以重新安装上一阶段缺少的两个软件包。现在一切都好了。

相关内容