ntpd: add nocerttimecheck option for NTS clients

Why

On a device without a battery-backed RTC the clock comes up far off at boot. Every NTS-KE server certificate then looks expired or not yet valid, NTS-KE never succeeds, and NTS can never set the clock it would need to validate the certificate. Today the only way out is noval, which turns off certificate validation entirely.

devel/nts.adoc already asks for a middle-ground option that validates the chain but ignores the certificate times. This is a reduced form of it.

What this changes

  • New nocerttimecheck option for server and pool with nts.
  • Until ntpd has set the clock for the first time, NTS-KE sets X509_V_FLAG_NO_CHECK_TIME. OpenSSL still verifies the chain, the signatures and the host name; only notBefore/notAfter are ignored.
  • A certificate that passed only because of that marks the association suspect (FLAG_NTS_CERTSUSPECT), with a warning in the log.
  • Once the clock is set, a suspect association drops its cookies and redoes NTS-KE with full validation. After that the option has no effect.
  • The clock counts as set at the first step or the first slew into sync, whichever comes first (sys_clock_synced). Without a drift file the first slew only follows the 300 s stepout interval, and a suspect association would keep serving until then.
  • Pools pass the flags on to the servers they spawn.
  • Documented in docs/includes/nts-commands.adoc, including the weakness: an attacker holding the key of an expired (or not yet valid) certificate for the server name can supply the initial time. devel/nts.adoc notes what is implemented. NEWS.adoc entry.

What it leaves out

The middle-ground mode in devel/nts.adoc also holds suspect associations back from selection and bounds the served time by the certificate validity period. Neither is implemented here.

Testing

  • This branch: builds without warnings and ./waf check passes, both default and --disable-nts (OpenSSL 4.0.1).
  • The functional tests below ran on 1.2.6 with this patch; rebasing onto master changed only the NEWS.adoc hunk.
  • Host, OpenSSL 4.0.1: server and client ntpd in separate network namespaces, both in lockclock mode, with a bench CA. Server certificate with notBefore in the future and nocerttimecheck: accepted as suspect, then "clock set, redoing NTS-KE", and the redo rejects it ("certificate is not yet valid"). Without the option it is refused. A wrong CA and a wrong host name are refused with the option. A valid certificate is not marked suspect and is not redone.
  • ARM device (AM335x, Linux 7.2, OpenSSL 3.6.5, no RTC battery), clock 13 days behind, ntpd -g, no drift file, server certificates valid for the true time but not for the device clock. Without the option: refused. Wrong CA, wrong address: refused. With the option, for both server and pool: accepted as suspect, clock stepped by 13 days, NTS-KE redone 1 to 3 s after the step and passed with full validation, device clock on the true time at the end. The pool's spawned server was re-keyed against the pool name, not its address.

This was written with an AI assistant (Claude; see the commit trailer) and tested on the hardware above.

🤖 Generated with Claude Code

Merge request reports

Loading
Loading