Skip to content

Commit e47957b

Browse files
committed
docs(time-sync): document the SNTP client and the signing gate
Signed-off-by: Bugs5382 <12115015+Bugs5382@users.noreply.github.com>
1 parent bf63e26 commit e47957b

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ internal/
2626
init/ # supervisor + boot bring-up
2727
netlink/ # NIC bring-up via rtnetlink
2828
mounts/ # early mount sequence
29+
timesync/ # client-only SNTPv4: boot step, periodic slew, clock floor
2930
tpm/ # go-tpm wrapper, SRK provisioning, crypto.Signer impl
3031
ca/ # RFC 5280 cert template builder
3132
ceremony/ # first-boot ceremony state machine
@@ -119,6 +120,8 @@ Every issued certificate comes from a named profile in the machine config. [`doc
119120

120121
A node keeps every certificate it issues. `cryptosctl ca list-issued` lists them, `ca get-issued --serial <hex>` prints one as PEM with its chain up to the root and its status (`valid`, `revoked` or `expired`), and `ca revoke` revokes one. [`docs/issued-certificates.md`](docs/issued-certificates.md) covers all three.
121122

123+
A node keeps its clock in sync over SNTP with the servers in `network.ntp_servers` (or its DHCP lease), and refuses to sign certificates until the first sync when a time source is configured. CRL and OCSP are never held up. [`docs/time-sync.md`](docs/time-sync.md) covers the servers, the signing gate and its `pki.allow_unsynced_clock` override, and the `Clock:` status line.
124+
122125
Issuing LDAPS and KDC certificates to Active Directory domain controllers, including `certreq` on Server Core, is covered in [`docs/active-directory.md`](docs/active-directory.md).
123126

124127
### Rebooting or powering off a node

‎docs/time-sync.md‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Time sync
2+
3+
A CA's clock sets the notBefore and notAfter of every certificate, the CRL's
4+
thisUpdate and nextUpdate, OCSP response times and audit times. A node keeps its
5+
clock in sync with a small client-only SNTPv4 (RFC 4330, and RFC 5905 section
6+
14) built into init. It never serves time.
7+
8+
## Configure the servers
9+
10+
```yaml
11+
network:
12+
interface: eth0
13+
address: 10.0.0.10/24
14+
gateway: 10.0.0.1
15+
nameservers: [10.0.0.53]
16+
ntp_servers: [10.0.0.123, time.example.org] # at most 3, IPv4 literals or hostnames
17+
```
18+
19+
A hostname is resolved through the node's resolver at every poll, so a DNS change
20+
takes effect without a reboot. `cryptosctl config apply` warns when a hostname
21+
is listed and `nameservers` is empty: the node then resolves it only if its DHCP
22+
lease supplies DNS servers.
23+
24+
With `ntp_servers` empty the node uses the NTP servers from its kernel DHCP
25+
lease (option 42), if it got any. With neither, the node runs on its hardware
26+
clock, and `config apply` warns about it. That is the expected setup for an
27+
offline Root.
28+
29+
## What the node does
30+
31+
- **At boot**, after the network and resolver are up and before etcd, the
32+
listeners and signing start, the node queries every server, retrying an
33+
unanswered one up to three times 2 seconds apart. It gives up after about
34+
10 seconds and boots anyway. An offset above 128 ms is stepped; a smaller one
35+
is slewed.
36+
- **After boot** it polls each server every 64 seconds, backing off to 1024
37+
seconds while a server does not answer. Small offsets are slewed. A forward
38+
offset above 128 ms is stepped. A backward one is refused and logged as an
39+
error, because it would reorder audit and issuance times on a running CA.
40+
- **Several servers:** the node takes the median offset. If two or more servers
41+
answered and their offsets are more than 1 second apart, it adjusts nothing
42+
and reports `sources disagree`. The 3-server limit and the 1-second window are
43+
fixed.
44+
- **Replies** are checked as RFC 4330 and RFC 5905 require. The request carries a
45+
random transmit timestamp that the reply must echo, and the socket only takes
46+
replies from the server it asked. A server that sends a kiss-o'-death `DENY` or
47+
`RSTR` is not queried again until reboot; `RATE` halves how often it is polled.
48+
- **The clock floor:** the clock is never stepped behind the latest of the image
49+
build time, the last good sync, and the latest notBefore the node has issued.
50+
The floor is kept on the encrypted state volume. A server whose time is behind
51+
it is refused and logged as an error.
52+
53+
The time is not authenticated (no NTS). The random nonce, the median and
54+
agreement rule, the floor, and the forward-only rule after boot limit what one
55+
bad or spoofed server can do.
56+
57+
## The signing gate
58+
59+
While a time source is configured or leased but the clock has not synced yet
60+
this boot, the node refuses to sign certificates: subordinate CA signing and
61+
every leaf path, including ACME and EST. The call fails with
62+
`FailedPrecondition` before the CA key is loaded. The gate opens at the first
63+
good sync and stays open for the rest of the boot, even if a later poll fails.
64+
65+
- A node with **no time source** is never gated.
66+
- **CRL and OCSP** are never gated. A stale-looking CRL is better than none.
67+
- `pki.allow_unsynced_clock: true` lifts the gate. Every certificate signed that
68+
way is logged as a warning. Leave it off in production.
69+
70+
```yaml
71+
pki:
72+
allow_unsynced_clock: true # sign on an unsynced clock (lab only)
73+
```
74+
75+
## Status
76+
77+
`cryptosctl status` prints a `Clock:` line: the state, the source and servers,
78+
then the server, offset, stratum and time of the latest good sync, or why the
79+
latest attempt did not adjust the clock.
80+
81+
```text
82+
Clock: SYNCED MACHINE_CONFIG 10.0.0.123, time.example.org (via time.example.org, offset -12.5ms, stratum 2, synced 2026-09-29T12:00:00Z, stepped at boot)
83+
Clock: UNSYNCED DHCP_LEASE 192.0.2.123: timesync: sources disagree: offsets spread 4.9s across 2 servers (more than 1s)
84+
Clock: NOT_CONFIGURED (no time source; running on the hardware clock)
85+
```
86+
87+
The states are `NOT_CONFIGURED`, `PENDING` (configured, no sync finished yet),
88+
`SYNCED` and `UNSYNCED`. The same fields are in `GetStatus` as `time_sync`.

0 commit comments

Comments
 (0)