docker ubuntu18.04镜像apt update报错Certificate verification failed

本文解决Docker环境下Ubuntu镜像使用HTTPS源时遇到的证书验证失败问题,提供手动安装ca-certificates及依赖包的方法。

公司环境使用docker的ubuntu:18.04镜像,因为公司网络限制,apt无法使用http源(我也不知道为啥。。。),改为https源后,apt update 报错Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification.

 

问题原因:

上网各种搜,最终发现大佬给出的正确答案:缺少ca-certificates包

 

 

解决办法:

因无法正常使用apt install(http源被禁,https源无法使用,如果能正常使用apt,直接apt install ca-certificates解决一切),需要手动安装ca-certificates包,要下载ca-certificates包还有libssl和openssl两个依赖包,按照如下顺序安装3个包后,再次apt update正常。(注意,我的版本对应ubuntu18.04)

dpkg -i libssl1.1_1.1.1-1ubuntu2.1_18.04.6_amd64.deb

dpkg -i openssl_1.1.1-1ubuntu2.1_18.04.6_amd64.deb

dpkg -i ca-certificates_20190110_18.04.1_all.deb

包下载路径如下(忘了打压缩包了,下载3次吧,反正不要分):

https://download.youkuaiyun.com/download/sc_goddog/12493173
https://download.youkuaiyun.com/download/sc_goddog/12493167
https://download.youkuaiyun.com/download/sc_goddog/12493135

 

--------------------------------------------------------------------------------------------------------------

补充ubuntu16.04的镜像无法使用https源解决方法,与ubuntu18.04类似,下载附件解压缩后执行setup.sh安装相关deb包即可

https://download.youkuaiyun.com/download/sc_goddog/12500401

 

 

WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Ign:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease Ign:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease Ign:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease Ign:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease Ign:5 https://apt.kitware.com/ubuntu bionic InRelease Ign:6 https://deb.nodesource.com/node_16.x nodistro InRelease Err:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Err:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Err:9 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Err:10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Err:11 https://apt.kitware.com/ubuntu bionic Release Could not handshake: Error in the pull function. [IP: 66.194.253.25 443] Err:12 https://deb.nodesource.com/node_16.x nodistro Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 104.20.45.190 443] Reading package lists... W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-updates/InRelease: No system certificates available. Try installing ca-certificates. W: https://deb.nodesource.com/node_16.x/dists/nodistro/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-backports/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-security/InRelease: No system certificates available. Try installing ca-certificates. W: https://apt.kitware.com/ubuntu/dists/bionic/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic Release' does not have a Release file. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-updates/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates Release' does not have a Release file. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-backports/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports Release' does not have a Release file. W: https://deb.nodesource.com/node_16.x/dists/nodistro/Release: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-security/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security Release' does not have a Release file. W: https://apt.kitware.com/ubuntu/dists/bionic/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://apt.kitware.com/ubuntu bionic Release' no longer has a Release file. E: The repository 'https://deb.nodesource.com/node_16.x nodistro Release' no longer has a Release file. The command '/bin/sh -c apt update' returned a non-zero code: 100
最新发布
11-08
### 解决 Ubuntu 24.04 中 `sudo apt update` 命令执行时遇到的错误 对于在 Ubuntu 24.04 上运行 `sudo apt update` 遇到的问题,有几种可能的原因以及相应的解决方案。 #### 关于 apt-news.service 的提示信息 如果仅是关于 `apt-news.service` 提示的信息,并不影响系统的正常使用。这类消息通常不会阻碍其他软件包管理操作的成功完成[^1]。 然而,若确实存在实质性错误,则可采取以下措施: #### 更新系统工具 确保安装最新的更新工具集可以帮助修复一些潜在问题: ```bash sudo apt update && sudo apt install ubuntu-news-tools -y ``` 这一步骤有助于同步本地索引至最新状态并获取必要的组件来支持后续的操作。 #### 清理重复或冲突的APT源列表文件 有时多个相同内容的仓库定义可能会引起冲突,移除不必要的自定义源能有效减少此类情况的发生几率。例如,如果有来自 Docker 官方站点的多余条目,可以通过下面命令将其删除: ```bash sudo rm /etc/apt/sources.list.d/archive_uri-https_download_docker_com_linux_ubuntu-noble.list ``` 此动作旨在消除任何可能导致混淆或冗余的数据源声明,从而简化依赖解析过程中的复杂度[^2]。 #### 修改默认镜像站地址为更稳定的国内资源库 考虑到网络连接质量差异等因素影响下载效率甚至成功率,在中国大陆地区推荐切换成清华大学开源软件镜像服务作为新的官方档案服务器位置之一。具体做法是在 `/etc/apt/sources.list.d/` 下创建一个新的 `.list` 文件用于指定清华源的相关参数设置: ```plaintext Types: deb URIs: http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg ``` 保存更改后再次尝试刷新缓存即可验证效果如何[^3]。 通过上述调整应该能够显著改善大多数情况下由于外部因素引起的 APT 资料库同步失败现象。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值