apt-get update 一直报证书错误 Certificate verification failed

20,261 阅读1分钟

起因是在 盒子上安装 debian,安装好以后,执行apt-get update 始终报错:

Err:9 mirrors.cloud.tencent.com/debian-secu… buster/updates Release Certificate verification failed: The certificate is NOT trusted. The certificate chain uses not yet valid certificate. Could not handshake: Error in the certificate verification. [IP: 111.231.36.190 443] Reading package lists... Done

E: The repository 'mirrors.cloud.tencent.com/debian-secu… buster/updates Release' does not have 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.

E: Release file for mirrors.cloud.tencent.com/debian/dist… is not valid yet (invalid for another 358d 15h 15min 43s). Updates for this repository will not be applied.

E: Release file for mirrors.cloud.tencent.com/debian/dist… is not valid yet (invalid for another 392d 0h 45min 16s). Updates for this repository will not be applied.

E: Release file for mirrors.cloud.tencent.com/debian/dist… is not valid yet (invalid for another 392d 0h 45min 15s). Updates for this repository will not be applied.

期间就算切换源 也没用, 切了各大学,各大企业 的源,都报 证书校验错误。

尝试强制在 /etc/apt/sources.list 添加 trusted=yes 也不行。

deb [trusted=yes] mirrors.ustc.edu.cn/debian/ buster main contrib non-free

各种更新证书的方式也试了,没有一个有效。

最后发现是 机器时间设置 问题,因为证书校验是 时间敏感的。 而我的机器时间还停留在去年。

搜到了 stackoverflow.com/questions/2… 这里,才看到了 答案:

Another cause of this problem might be that your clock might be off. Certificates are time sensitive. To check the current system time:

date -R

You might consider installing NTP to automatically sync the system time with trusted internet timeservers from the global NTP pool. For example, to install on Debian/Ubuntu: apt-get install ntp

apt-get install ntp

耽误了得有一天时间, 罪过!