更新软件源报错The certificate is NOT trusted

有时在使用apt update命令更新软件源时会碰到一个问题

Certificate verification failed: The certificate is NOT trusted.

一番检查过后发现软件源配置并无问题,此时可以回想一下系统是否是mini安装。

mini安装的系统缺少时间同步软件,会因为时间错误导致误认为SSL证书失效,可以使用date命令查看系统当前时间。

网上搜索到的教程大多是教你安装ntpdate,还要配置一个systemd服务。

但正常来说系统会自带一个同步软件,对于使用systemd管理的linux,可以安装其原本应该自带的systemd-timesyncd,该软件默认集成于Debian12中。

首先使用timedatectl status检查输出,其输出应如下图所示。

               Local time: 四 2026-08-06 23:35:50 CST
           Universal time: 四 2026-08-06 15:35:50 UTC
                 RTC time: 四 2026-08-06 15:35:50
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

System clock synchronized项显示为no,则代表无同步设置。

此时应检查系统是否安装systemd-timesyncd

dpkg -l | grep systemd-timesyncd

无任何输出则代表未安装,直接安装即可。

以上发现主要来自debian12系统如何设置自动同步时间 – 春日野喵的小窝↗