Fix invalid PGP signatures caused by a wrong system clock
AUDITED Audited against its sources and confirmed accurate.
Symptom
On a fresh install, a dual-boot machine, or after a dead CMOS battery:
error: PackageName: signature from "User <email@archlinux.org>" is invalid
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.
Reinstalling the keyring does not help.
Cause
pacman-key/GnuPG validates signatures against the system clock. If the clock is in the past or the future, valid keys look expired or not-yet-valid, and TLS certificate checks on HTTPS mirrors fail too. Windows dual-boot writing localtime to the RTC is the usual culprit.
Fix
timedatectl # look at 'System clock synchronized' and 'RTC in local TZ'
sudo timedatectl set-ntp true
sudo systemctl restart systemd-timesyncd
timedatectl # confirm the time is now correct
sudo hwclock --systohc # write the corrected time back to the RTC in UTC
sudo pacman -Syu
If you dual-boot Windows, make Windows use UTC as well rather than switching Linux to localtime. In an elevated Windows cmd:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /t REG_DWORD /d 1 /f
Verify
timedatectl shows System clock synchronized: yes and the correct date. sudo pacman -Syu no longer reports invalid signatures.
Sources
pgp-signature-invalid-wrong-system-clock