Ubuntu中apt更新时报错The certificate issuer is unknown的解决办法

Ubuntu 22.04更新apt出现The certificate issuer is unknown的解决办法

问题描述

使用docker安装Ubuntu22.04,官网给出的镜像只是一个裸系统,预装软件很少。换阿里源以后,apt update,出现如下报错:

shell 复制代码
# apt update
Ign:1 https://mirrors.aliyun.com/ubuntu-ports jammy InRelease
Ign:2 https://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease
Ign:3 https://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease
Ign:4 https://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease
Ign:1 https://mirrors.aliyun.com/ubuntu-ports jammy InRelease
Ign:2 https://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease
Ign:3 https://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease
Ign:4 https://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease
Ign:1 https://mirrors.aliyun.com/ubuntu-ports jammy InRelease
Ign:2 https://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease
Ign:3 https://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease
Ign:4 https://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease
Err:1 https://mirrors.aliyun.com/ubuntu-ports jammy InRelease
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.76 443]
Err:2 https://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.77 443]
Err:3 https://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.76 443]
Err:4 https://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.77 443]
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-security/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-updates/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-backports/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-security/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-updates/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-backports/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-security/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-updates/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-backports/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-security/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-updates/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-backports/InRelease: No system certificates available. Try installing ca-certificates.
W: Failed to fetch https://mirrors.aliyun.com/ubuntu-ports/dists/jammy/InRelease  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.76 443]
W: Failed to fetch https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-security/InRelease  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.77 443]
W: Failed to fetch https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-updates/InRelease  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.76 443]
W: Failed to fetch https://mirrors.aliyun.com/ubuntu-ports/dists/jammy-backports/InRelease  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 222.192.186.77 443]
W: Some index files failed to download. They have been ignored, or old ones used instead.

重点出在了The certificate issuer is unknown. 上,这个错误通常表示 SSL/TLS 证书的颁发机构未知或无法验证。网上给出的方法有很多,但是或多或少都要用到一些需要安装的工具,而裸系统上都没有。

解决办法

  1. httpshttp。以阿里云镜像为例,直接将以下脚本拷贝到终端运行,将apt配置写入/etc/apt/sources.list
sh 复制代码
# 清空当前 sources.list
bash -c 'echo "" > /etc/apt/sources.list'

# 写入新的源列表
tee /etc/apt/sources.list <<EOF
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse

# deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
EOF
  1. 运行apt update。问题解决,成功更新。
  2. 考虑到http终归不安全,安装证书并更新。
sh 复制代码
apt install ca-certificates
update-ca-certificates

然后,将/etc/apt/sources.listhttp改回https

讨论

  • 换源时要去官方站点,CSDN博主分享的一些配置文件可能已经失效。官方站点中应有尽有,例如阿里云的站点。
  • 在没有vim等编辑器的情况下,可以借鉴上文笔者的方法,使用命令行的方式编辑文件。
相关推荐
拾光Ծ1 小时前
【Linux】冯诺依曼体系结构和操作系统概述
linux·硬件架构
hfut02882 小时前
第25章 interface
linux·服务器·网络
Sinowintop4 小时前
易连EDI-EasyLink SFTP文件传输
运维·服务器·网络·sftp·edi·ftp·国产edi软件
likuolei5 小时前
XML DOM 节点类型
xml·java·服务器
风123456789~6 小时前
【Linux专栏】显示或隐藏行号、批量注释
linux·运维·服务器
只想安静的写会代码7 小时前
centos/ubuntu/redhat配置清华源/本地源
linux·运维·服务器
susu10830189117 小时前
ubuntu多块硬盘挂载到同一目录LVM方式
linux·运维·ubuntu
r***F2627 小时前
【漏洞复现】CVE-2019-11043(PHP远程代码执行漏洞)信息安全论文_含漏洞复现完整过程_含Linux环境go语言编译环境安装
linux·golang·php
贝锐8 小时前
Docker部署Teemii本地漫画库,并通过花生壳内网穿透实现远程访问
docker
smaller_maple9 小时前
linux问题记录1
linux·运维·服务器