qqt

Cert custody

Cert custody, re-minting and offboarding

The CA key stays with the operator; role sets ship to their machines; a customer’s cert sits under their own CA. The runbook for all three.

The operational procedure for re-issuing a customer’s cert when one expires or leaks, and the minting flow that keeps every fleet-admitting key with its customer instead of the house. Read instructions_qqt-howto.md §2 for the basic cert layout first; this doc assumes it.

1. The custody model

Two kinds of key material, deliberately unequal:

  • Server-identity CA (gencert’s CA, in the per-customer model below): signs the server cert the clients verify. Its key stays with the operator, and in that model it is not fleet-admitting — it mints nothing that opens a door, only something that impersonates the door, because no customer cert chains to it. Keep it off the server boxes anyway. (In the one-operator model of §6 that same key signs the client set too, and there it is admitting — §6 spells out that trade.)
  • Customer CAs (mint’s output): each customer’s client cert chains to their own CA. The CA key is the admitting power for exactly that customer, and it belongs to the customer — ideally minted on their box, never returned to the operator. The CA cert is public and is written to the server’s trust bundle.

The server’s ca-cert.pem is a bundle: every CA cert in it admits the chains below it. Admission of a customer is appending their CA cert; revocation is a fingerprint on the deny-list — the bundle itself only changes when you add or offboard a customer.

Trust rule for the per-customer model: do not put the operator’s gencert CA cert in the server’s trust bundle. The bundle should hold customer CAs only (plus, if you run the simple single-CA model, see §6). That way even a stolen operator keyset mints no admitting cert.

2. Per-customer minting (first issue)

The customer-minted flow — the operator never touches the admitting key:

  1. The operator sends the customer two public files: the server-identity CA cert (from gencert’s output, ca-cert.pem at the root or either role dir) and the qqt binary.

  2. On the customer’s box, the customer runs:

    qqt mint --customer acme --server-ca ./server-ca.pem -o ./certs

    producing (without -o the same tree lands under ~/.local/state/qqt/certs, so name the directory you mean):

    certs/acme/
    ├── ca-cert.pem        the customer's CA cert — public
    ├── ca-key.pem         the customer's CA key — stays with the customer
    └── client/
        ├── ca-cert.pem    the server-identity CA (copied from --server-ca)
        ├── client-cert.pem
        └── client-key.pem

    mint verifies the fresh client cert actually authenticates against the fresh CA before writing anything — a set that would not connect fails at mint with the TLS cause.

  3. The customer sends only ./certs/acme/ca-cert.pem back to the operator. The CA key never leaves their custody.

  4. The operator admits the customer by appending that cert to the server’s bundle:

    cat ./certs/acme/ca-cert.pem >> /etc/qqt/server-certs/ca-cert.pem

    and restarting the server (roots load at startup — a bundle change is the one cert operation that needs one; the fingerprint list in §4 never does).

  5. The customer connects with --certs-dir certs/acme/client.

The operator-minted fallback (customer can’t run the binary): the operator runs the same mint and ships certs/acme/ to the customer over a trusted channel, then deletes their copy of ./certs/acme/ca-key.pem. The custody goal is “the house does not hold the key”, not “the key was never on house disk” — deleting after handoff restores it.

3. Expiry rollover (the routine re-mint)

Client certs live 365 days by default (--valid-days at mint; the TLS handshake enforces the window on both sides, so an expired cert stops admitting on its own). The customer CA lives 3650 days, so ~nine leaf generations re-mint under it with no server-side change.

On the customer’s box:

  1. Watch the window — qqt expiry is the cron-able gate (exit 1 when any cert is expired or not yet valid):

    qqt expiry ./certs/acme/client/client-cert.pem
  2. Preserve the cert you are retiring, then re-mint the leaf under the existing CA (this is why the CA key lives with the customer). Copy it aside FIRST: the re-mint overwrites client-cert.pem in place, and step 4 has to name the old one:

    cp ./certs/acme/client/client-cert.pem ./certs/acme/retired-cert.pem
    
    qqt mint --customer acme \
        --ca-cert ./certs/acme/ca-cert.pem \
        --ca-key ./certs/acme/ca-key.pem \
        --server-ca ./server-ca.pem \
        -o ./certs -f

    -o ./certs is required: without it mint writes to ~/.local/state/qqt/certs, a different tree from the one the client runs with, and the expired leaf would stay installed. -f replaces the existing pair. The server’s bundle is untouched — the CA did not change, so there is nothing to re-admit and nothing to restart.

  3. Swap the running client to the new cert (restart the client; a redial is a fresh handshake, so the new cert authenticates on the next connect).

  4. Revoke the RETIRED cert so it cannot come back (it is still valid until its window closes — expiry alone does not retire it early, and a decommissioned machine still holds a working cert):

    qqt revoke --cert ./certs/acme/retired-cert.pem --revoked revoked.txt

    The client’s client-cert.pem is a leaf-plus-CA chain; revoke takes the leaf (the end entity) and names the fingerprint it killed, so a re-mint under the same CA is unaffected. Revoking the freshly-minted file by mistake is the trap this copy exists to close. To offboard the whole customer instead, point --cert at their CA PEM — that is a different, deliberate act.

    Ship the updated list to the server (see §4 for the mechanics).

When the customer CA itself approaches expiry (check with qqt expiry certs/acme/ca-cert.pem), re-issue the whole customer set as a fresh mint (§2) and remove the old CA cert from the bundle when the last leaf under it is gone. This is hygiene, not retirement: the server does not date-check a CA, so an expired one keeps admitting until you remove it from the bundle or revoke it. Re-issuing on schedule keeps the bookkeeping honest; it is not what closes the door.

4. Leak response (a client key or cert escapes)

The deny-list is the whole mechanism: SHA-256 fingerprints, one per line, # comments, re-read by the server at every handshake — so an entry bites at the next connect with no restart, no re-mint of the fleet, no bundle edit.

# on whichever box holds the cert that leaked — prints the fingerprint
qqt revoke --cert /path/to/leaked-client-cert.pem --revoked /etc/qqt/revoked.txt
  • The list file lives on the server box (--revoked /etc/qqt/revoked.txt on the server’s start line — add it to the boot guard too, or a reboot comes back revocation-blind; up --revoked starts it and warns when the box’s boot guard lacks the flag). If you revoke on the operator box, ship the appended file like you ship certs.
  • revoke is idempotent (an existing fingerprint is a no-op) and fsyncs — a revocation must survive a power cut.
  • The check covers the whole presented chain and, beyond it, the leaf’s issuer resolved from the server’s own trust bundle, one hop: revoking a leaf kills that one cert; revoking a customer’s CA cert kills every leaf it signed directly, present and future — including one minted after the revocation, and including a client that presents its leaf without a CA block. A leaf under the customer’s own intermediate survives it; offboard that customer by removing their CA from the bundle.
  • Honest bounds: the check sits on the admit path, after the handshake — a revoked holder’s failed connect reads as a closed connection, and a connection already live when the list changes keeps its streams until it drops or the server restarts. To cut a live session of a revoked holder, restart the server.
  • The list file must not be attacker-writable on the box: whoever can edit it can un-revoke.

Full drill for a leaked client key:

  1. Revoke the leaked cert (above) — future handshakes die immediately.
  2. Restart the server if cutting the leaked holder’s live connection cannot wait for it to drop.
  3. The customer re-mints the leaf under their CA (§3 step 2) and restarts their client. Done — the server never changed.

5. Offboarding a customer (or a leaked customer CA key)

Revoking the customer’s CA cert is the kill switch — every cert that customer has minted or will mint under it dies at the next handshake:

qqt revoke --cert ./certs/acme/ca-cert.pem --revoked /etc/qqt/revoked.txt

Bundle hygiene afterwards: once the deny-list has held the CA cert through any operational margin you care about, delete its PEM block from the server’s ca-cert.pem (a text edit — each block starts at its -----BEGIN CERTIFICATE----- line), keep the fingerprint on the list (the list, not the bundle, is what stops re-admission by a bundle mistake), and restart the server. A customer CA that leaked its KEY (not just the cert) is an offboarding plus re-admission of a replacement: treat the customer as new (§2) with a fresh mint.

6. The simple model (one operator, one CA)

gencert alone still covers the single-trust-domain case: one CA signs the server cert and the client set, the CA key stays with the operator, and that key IS fleet-admitting — the trade the simple model makes for having one file to ship. The simple model gets the same window (--valid-days, default 365) and the same deny-list; its leak response is the same §4 drill, and its rollover is gencert -f --valid-days N plus re-shipping both role dirs (the CA changes with it, so the server restarts — the one case where a routine rollover costs a restart; the per-customer model exists to make that never necessary).

7. What still cannot be done

  • No CRL, no OCSP — the deny-list is a flat file the server polls per handshake. For the fleet sizes qqt serves this is the honest mechanism; the bounds are in architecture_qqt-limitations.md.
  • The client has no revocation check of its own: the server-identity CA is verified for signature and window, but a leaked server key (not CA key) is answered by re-minting the server set (gencert -f) and re-shipping server/ — the old server cert then fails signature verification only after the CA rotates. A leaked server-identity CA key is impersonation-grade: rotate the whole set.
  • Bundle edits (adding/removing a CA) load only at server startup — the one cert operation that needs a restart.

← All documentation