apt-get 更新失败,因为证书验证失败,因为 nodesource 上的握手失败

Joe*_*Joe 18 updates apt ssl nodejs 18.04

sudo apt-get update在我的AWS EC2 Ubuntu的LTS 01年4月18日实例失败,因为我的证书验证失败:证书不被信任。尝试访问deb.nodesource.com/node_10.x 仿生版本,证书颁发者未知

这是运行后的结果 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.
Run Code Online (Sandbox Code Playgroud)

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

我试着安装和更新ca-certificatesetc/ssl/certs,但是,这并没有帮助。我不确定如何从这里着手解决这个问题。

我不是在寻找会损害服务器安全性的快速解决方法。

提前致谢!

小智 34

对于仍然遇到此问题的人,这里是我从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]
Run Code Online (Sandbox Code Playgroud)

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

touch /etc/apt/apt.conf.d/99verify-peer.conf \
&& echo >>/etc/apt/apt.conf.d/99verify-peer.conf "Acquire { https::Verify-Peer false }"
Run Code Online (Sandbox Code Playgroud)

这会禁用 apt 的 OCSP 验证,因此不建议这样做。

我选择了不同的解决方案,其他人可能无法使用该解决方案。我们公司为这样的用例维护了一个非解密代理,所以我转而使用它。

  • 提前谢谢你,它可以工作 (2认同)

小智 16

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

sudo apt install ca-certificates
Run Code Online (Sandbox Code Playgroud)

  • 谢谢-这实际上解决了问题而没有绕过安全性。 (3认同)
  • 这应该是一个可以接受的答案。今天在 18.04.* 容器内遇到了同样的问题,安装“ca-certificates”解决了它。谢谢! (2认同)

Mik*_*.C. 15

您可以[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
Run Code Online (Sandbox Code Playgroud)

  • 嗨迈克。如上所示,使用“[trusted=yes]”更新“/etc/apt/sources.list”和“/etc/apt/sources.list.d/nodesource.list”后,我仍然看到相同的错误。 (4认同)
  • 如果您通过使用 ZScaler 或类似工具的某个地方进行 VPN,那么您也可能会遇到这个问题。就我而言,我只需关闭 VPN,更新就可以完美完成。 (4认同)

LSe*_*rni 7

今天,我在一个旧的、维护不善的 Ubuntu 16 版本上发生了这种情况。

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

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

所以:

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

    Acquire { https::Verify-Peer false }
    
    Run Code Online (Sandbox Code Playgroud)

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

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

  3. 跑步apt install ca-certificates

  4. 重新启用证书验证

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

现在一切应该都可以正常工作了。

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

经过几个小时和从 18 的另一个版本升级后,我得到了运行 Ubuntu 20.04-LTS 的系统,并且可以重新安装前一阶段丢失的两个软件包。现在一切都好了。


小智 6

确保您的日期和时间设置正确。


小智 5

您可以使用 sed 从安装脚本中替换https://为。http://

curl -sL https://deb.nodesource.com/setup_10.x | sed 's|https://|http://|' | sudo -E bash -
Run Code Online (Sandbox Code Playgroud)

当然,这应该作为最后的选择。