5
Self-Signed-TLS-Trust-Bootstrap
gsadmin edited this page 2026-08-11 10:23:34 +00:00

Self-Signed TLS — automatic trust bootstrap

Self-signed TLS normally means work for an operator: export the server's CA, then import it into the trust store of every endpoint — or, worse, turn off certificate verification everywhere and never turn it back on.

ExecuteR removes that step. On first contact an agent tries a normally-validated connection; only if that fails (a self-signed server, first contact) does it anchor trust — and even then it installs the CA only after checking it against a fingerprint baked into the bootstrap token. No files to copy, no per-machine import, no fleet-wide "skip verify", and no trust-on-first-use gap.

The flow

flowchart TB
    subgraph AGENT["Agent (endpoint)"]
        A1["Enroll: try a normally-validated connection"]
        VALID{"Certificate validates?"}
        FETCH["Fetch CA over accept-any probe"]
        VER{"Fetched CA matches fingerprint in token?"}
        INS["Install CA, then enroll (validated)"]
        OK["Enrolled. Ongoing refresh is authenticated"]
        STOP["Abort (possible MITM)"]
    end

    subgraph SERVER["Control plane (server)"]
        API["Bootstrap + GET /api/enrollment/ca"]
        MGR["Managed self-signed CA (root renewed in place, same key)"]
    end

    A1 --> VALID
    VALID -->|"yes (real cert, or CA from a prior run)"| OK
    VALID -->|"no (self-signed, first contact)"| FETCH
    FETCH <-->|"accept-any, fetch only, no secrets"| API
    FETCH --> VER
    VER -->|"match"| INS
    VER -->|"mismatch / 404 / no fingerprint"| STOP
    INS --> OK
    OK <-->|"validated HTTPS + periodic CA refresh"| SERVER
    MGR -. serves public certs .-> API

The fingerprint in the token

When the server runs the managed self-signed chain, a minted bootstrap token is secret.<sha256-of-root-key> — the fingerprint is a hash of the root CA's public key (its SubjectPublicKeyInfo), a pin, not a credential. Hashing the key rather than the certificate keeps the pin stable when the root is renewed in place (same key, re-issued cert). It rides wherever the token already goes (the install command, the MSI BOOTSTRAPTOKEN), so there is no separate value, endpoint, or flag. The server hashes the whole token string, so enrollment validation is unchanged; the agent parses the fingerprint locally and matches it against the root's key in the fetched chain.

The 200 / 404 signal

GET /api/enrollment/ca is anonymous, and its presence is the signal:

  • 200 + chain — the server terminates TLS with its managed self-signed CA and returns the public chain (root + intermediate), never a private key.
  • 404 — the route does not exist, so the server is not self-signed (a real certificate, often at an edge proxy, is terminating TLS). Nothing to install.

Why the accept-any probe is safe

The one probe runs with certificate validation off, but only to fetch the anchor; the agent then pins it — the fetched CA must match the token's fingerprint before it is installed. The transport is untrusted by design; the fingerprint, carried out-of-band in the token, is what authenticates it. A mismatch (or a 404, or no fingerprint) aborts enrollment. Every call after the bootstrap validates normally against the OS trust store.

Why this greatly simplifies manual trust bootstrapping

  • No CA distribution. Nothing to export, copy, or certutil / keychain-import on each machine.
  • No standing insecurity. No fleet-wide "trust all certificates" knob; the one accept-any fetch is verified against the pin, then trust is normal.
  • One command, either topology. The same install works self-signed or fronted by a real certificate — the branch is decided at connection time, not by config.

Security and topology

First-contact MITM is closed. The accept-any fetch would otherwise be trust-on-first-use — an on-path attacker could substitute a CA. Pinning the fetched CA to the token's fingerprint prevents that: the attacker would need the fingerprint, which travels out-of-band with the token, never on the wire. A server-only "proof" cannot help (a MITM signs with its own key and it self-verifies), which is why the anchor is tied to the token.

Fronted by a real certificate — no needless install. Enrollment is connection-first: it tries a validated connection and, if the certificate already validates (a real/edge cert, or a CA installed on a prior run), it installs nothing. Terminate at an edge proxy with a real cert and agents just validate; the 404 path installs nothing either.

Rotation is seamless. The leaf rotates yearly and the intermediate less often, all under the same root the agent already trusts — transparent. When the root reaches its renewal margin it is renewed in place with the same key: only the certificate's validity is extended, so the whole chain keeps validating for already-enrolled agents. The agent's periodic refresh runs over its already-validated connection and installs the renewed root before the old cert expires — no operator action, no re-enrollment. A true root key rotation (e.g. after a compromise) is a deliberate event: it can't validate against the old trust, so it re-tokens new agents while existing ones are re-enrolled — exactly the boundary you'd want a key change to have.

See also: Networking and TLS.