carlos / platform Public

Import existing certificates for custom domains before a DNS move open

From Tito (carlos-infrastructure-e7), with Paul's go.

Tito Pro serves about 70 customer-owned custom domains (e.g. rsvp.juxt.pro, ticketing.stripeyste.com, lionforum.org). Customers control their DNS; today their names CNAME to Tito, and Kubernetes cert-manager holds a valid Let's Encrypt certificate for each, via HTTP-01.

When Pro moves to CARLOS (fleet tito-production), each name only gets a certificate over HTTP-01 after it points at CARLOS (#1293 answer 3). That means a few minutes of TLS errors per name, and all ~70 at once if one shared target moves. #1293's pre-issue doesn't help, because these zones aren't ours (no DNS-01).

Ask: a supported way for an operator to import an existing certificate and key for an attached custom domain into control/certs/<host>, so every edge serves it before DNS moves. CARLOS then takes over renewal (HTTP-01 once the name points here) before the imported one expires. For example, carlos domains cert import <host> --cert fullchain.pem --key key.pem: checks the chain covers the host and is unexpired, encrypts the key at rest like issued ones, and is audited. Deployment-operator only.

We'd export from cert-manager's Secrets (tls.crt/tls.key) per name, import, check with curl --resolve on a non-hub edge, then move the shared CNAME target.

Rough date? Pro is the last app off Kubernetes. Classic goes first (around 11-29+), then Pro.

Picked up by the platform builder (from 8a3d302, on Paul's go). Branch: cert-import-1429. Rough date: built, reviewed and merged by 2026-12-01. Release and Tito's use of it are Paul's go.

The design is on the branch: 2026-11-25-cert-import-1429-design.md. Astra and Fable are reviewing it now. In short:

  • carlos domains cert import <host> --cert fullchain.pem --key key.pem. Platform operators only (a person, not a token for an app), inside the account that holds the name. The name must be attached already, not pending, and an exact name.
  • The console checks that the key matches the certificate, the chain leads to a public root, the certificate covers the name, and that it has more than 7 days left. A wildcard that only covers the name as *.parent needs --allow-wildcard. Refusals never repeat the key or the certificate back.
  • It's stored like the certificates CARLOS issues (same bucket prefix, same encryption at rest), under its own name, control/certs/<host>+import. Nothing logs it.
  • Every edge serves it straight away, and the home box publishes the name before DNS points, so every edge relays it. CARLOS's own certificate always wins once there is one.
  • After the DNS move, CARLOS orders its own certificate over HTTP-01 as usual (the import covers the minutes in between), then deletes the import.
  • carlos domains cert remove <host>, or detaching the name, deletes it on every edge within about 30 s.

For Tito, the recipe once released: export tls.crt/tls.key per name from cert-manager, import each, check one with curl -sv --resolve <host>:443:<non-hub edge IP> https://<host>/, then move the shared CNAME target. If the move slips past a certificate's expiry, import the renewed one again: CARLOS can't renew an import before the name points here.

Revised date: merged by 2026-11-27, ready for a release on 2026-11-28 (the release is Paul's go), so Tito can rehearse on staging before the Pro switch on Sunday 11-29.

Both reviews stay: Astra and Fable on the spec and on the code. Spec round 1 is back. Astra found three P1s and Fable none, and the fixes are going into rev 2 now:

  • An import is tied to the claim that authorized it (the account and the attach), and checked when a name is published early and when the import is cleaned up.
  • No box orders a certificate for an imported name before DNS points here, including the issuer when it is also the home box.
  • Each visitor gets the certificate that suits their client. The import stays until it expires instead of being removed as soon as CARLOS has its own, so clients that only take RSA keep working.

What can't be squeezed is a review round that finds another P1. Each extra round costs about half a day. If round 3 of either review still finds a P1, the rules say it goes to Paul to cut scope, and the date would slip to Saturday or later. I'll say so here the moment that happens.

Spec round 2: stopping rule 2 applies. I need Paul's choice before a third round.

  • Fable R2: READY AFTER FIXES, no P1. One P2: a claim read that fails must not count as "detached". A second P2: say whether Tito Pro's home box mirrors certificates.
  • Astra R2: NOT READY, four P1s. Two of them repeat round 1's fault families, so rule 2 says stop patching and ask. Both findings are in ASTRA-FINDINGS-SPEC-R2.md.

The two recurring families:

  1. An import must stay tied to the claim that authorized it. An import that pauses mid-request can overwrite a later owner's import. My write retried with a fresh read of the object's ETag, which defeats the check. The claim's created_at is only second-granular. And the cleanup reads claims through ClaimCache.List, which turns a failed claim read into "gone" and would delete a live import. A related P1: the existing expiry sweep deletes without a condition, so it can delete a fresh re-import.
  2. Each client must get a certificate it can use. My handshake layer checks that some suitable CARLOS certificate exists, then hands over to the inner chain, which picks its own (by an older test that misreads TLS 1.3-only clients) and can return the unsuitable one.

Options (rule 2):

  • A. One invariant per family, each enforced in one function, with a randomized interleaving test. (Recommended; Astra recommends the same.) - Binding: the console writes one conditional Put. On a conflict it re-reads the claim and the object from scratch and validates again, never retrying blind. The binding uses the claim's acq where the claim has one, otherwise created_at plus the claim's revision. One issuer function, reconcileImports, is the only deleter: it uses ListWithUnread, keeps anything whose claim it couldn't read, deletes with DeleteIfMatch, and does import expiry itself. The generic sweep skips +import. - Selection: for a name with an import, one function chooses among the CARLOS entries and the import with hello.SupportsCertificate and returns that certificate itself. Names without an import are unchanged. - A simulation test runs random import, detach, re-attach, remove and failed-read sequences and checks that the invariant holds after every step. - Cost: about half a day, then round 3 with both reviewers, the last allowed. Date holds at merged by 11-27 if round 3 has no P1; otherwise it comes back to Paul.
  • B. Refuse up front. Import only while the name has no other import and the claim has an acq, and refuse detach while an import exists (the operator removes it first). That removes the ownership races, though it may refuse Tito's existing claims if they lack an acq. Selection still needs the fix from A.
  • C. Cut. Serve imports only to clients the import suits, with no CARLOS preference while one exists (the import wins until it expires). That removes family 2. Family 1 still needs A or B.

Builders are already working on the parts no option changes: validation, the CLI, the mirror's disk reconcile and the HostPolicy refusal.

Paul chose option A (2026-11-26). Rev 3 of the design is on the branch: one invariant per fault family, each enforced in one function, with a randomized interleaving test.

  1. An import stays tied to the claim that authorized it. internal/domains has the only writer, the only remove and the only rule for deleting during cleanup. Every write and delete is conditional on the revision it read, and a claim that can't be read is never treated as detached. A simulation interleaves imports by two accounts with detaches, re-attaches, removes, cleanup passes and injected failures, and checks the invariant after every step.
  2. Each client gets a certificate it supports. For a name with an import, one function picks among CARLOS's certificates and the import using SupportsCertificate, and returns that certificate itself. A randomized test covers TLS 1.2 and 1.3 client shapes.

Already done: both halves are built, Luna's copy is applied, and Tito confirmed the fleet-hub hosting and that host-claim mode is off. Round 3 (Astra and Fable, spec and code) starts when the invariants land later today. Still on track: merged by 11-27, ready for a release on 11-28.

Round 3 (the last): Fable READY AFTER FIXES; Astra NOT READY with one P1. Paul's call needed.

The P1 is in the recurring certificate-selection family. The wildcard layer sits above the import layer. So for a name that has an import AND is covered by a CARLOS wildcard certificate, an RSA-only client gets the ECDSA wildcard and fails, even though the RSA import would have worked. Pro's customer domains are never under a CARLOS wildcard (they're customers' zones), so this doesn't touch Tito's move. It matters for a general-use platform.

Options (rule 1: a P1 in round 3 goes to Paul):

  • 1. Refuse up front, plus one guard. (Recommended.) The import door refuses a hostname a wildcard certificate already covers; Fable flagged that such an import is never served anyway. If a wildcard arrives after an import, the wildcard layer steps aside for any exact name with a usable import, and the selection function counts the wildcard as a CARLOS candidate. Both halves are being built now as separate commits, so either can be dropped. Then merge after CI and the census check, without a fourth review round.
  • 2. Refuse up front only. The door refusal without the guard. Simpler, but a later wildcard can still recreate the case.
  • 3. A fourth round after option 1, for Astra to confirm. About half a day: merge on 11-27 evening at the earliest.

Being fixed now under rule 1 (P2s, no reopening):

  • A failed confirm can no longer silently delete a working import (Fable P2-1, Astra P2-2): retries, a separate context for the withdrawal, and an explicit error.
  • The home box's file checks become one no-follow, non-blocking, size-capped read whose bytes decide everything. This also answers Astra's census rejection of four units, and Astra re-checks the census on the fix.
  • The cleanup can't be starved by five failing names.
  • The docs give the real removal timing: usually seconds, at worst 30 minutes.

Findings: ASTRA-FINDINGS-R3.md and FABLE-FINDINGS-R3.md. Date: with option 1 or 2, still merged by 11-27.

Merged as 18d6456 (2026-11-26). Not released: the release, and Tito's use of it, are Paul's go.

What Tito does once a release with it is on every production box (old boxes neither serve imports nor publish them early):

  1. Per name, export tls.crt and tls.key from cert-manager's Secret.
  2. carlos domains cert import <host> --app tito-pro --cert tls.crt --key tls.key as a platform operator who is a member of the account holding the name. The answer shows the issuer, expiry and SHA-256. A certificate with 7 days or less left is refused. So is a name already covered by a CARLOS wildcard. A certificate that only covers the name through a wildcard (*.example.com) needs --allow-wildcard.
  3. Check one name on a non-hub edge: curl -sv --resolve <host>:443:<UK edge IP> https://<host>/ -o /dev/null should show the imported certificate and the app's answer. The hub (IE) publishes the name before DNS points, so this works up to about 7 minutes after the import.
  4. Move the shared CNAME target. Every edge serves the import straight away. CARLOS orders its own certificate once each name is seen pointing here (5 to 7 minutes), and from then on serves it to every client it suits.
  5. If the move slips past a certificate's expiry, import the renewed one. carlos domains cert remove <host> withdraws an import: edges usually stop serving it within seconds, and within 30 minutes while storage is working.

Pro's two ti.to names can be imported the same way for Sunday (see #1441).

Review trail: spec rounds 1 to 3 with Astra and Fable. After round 2, Paul chose option A: one invariant per fault family, with a randomized interleaving simulation. After round 3 he chose option 1: wildcard-covered names are refused, with a guard and a deterministic test. Astra approved the census on #280 after two re-checks. Luna reviewed the copy in three passes. CI passed; the first run hit a race-timing flake in an unrelated console-socket test.