SSL

Automatic HTTPS for every site with ACME, wildcard certificates, renewal, custom certificates and CSRs.

Available ssl version 1.0.1 Part of SSL certificates

Actions

29 actions, callable from the panel, the command palette and the API as POST /api/v1/a/<id>. Internal actions used between modules are not listed.

ActionWhat it doesRiskPreview
ssl.app_domain.ensure Ensure the server app-domain certificate medium
ssl.app_domain.status Status of the server app-domain certificate (read) low No dry run
ssl.ca.list List certificate authorities (read) low No dry run
ssl.ca.add Add a certificate authority high
ssl.ca.update Change a certificate authority high
ssl.ca.remove Remove a certificate authority high
ssl.ca.test Test a certificate authority (read) low No dry run
ssl.cert.issue Order a certificate low
ssl.cert.renew Renew now (or retry) low
ssl.cert.upload Upload a custom certificate medium
ssl.cert.attach Attach a certificate to a host medium
ssl.cert.delete Delete a certificate medium
ssl.cert.revoke Revoke a certificate high
ssl.cert.list List certificates (read) low No dry run
ssl.cert.get Get a certificate (read) low No dry run
ssl.csr.create Generate a CSR low
ssl.selfsigned.create Create a self-signed certificate low
ssl.check Check the served certificate (read) low No dry run
ssl.wildcard.check Can a wildcard certificate be issued here? (read) low No dry run
ssl.https.set Force HTTPS for a site low
ssl.cert.precheck Check names before ordering a certificate (read) low No dry run
ssl.cert.use_wildcard Use the domain's wildcard certificate medium
ssl.cert.choices Certificates that can serve an address (read) low No dry run
ssl.cert.usage Where a certificate is used (read) low No dry run
ssl.cert.use_for Use a certificate for more addresses medium
ssl.cert.cleanup Remove unused certificates medium
ssl.cert.detach Stop using a certificate on an address medium
ssl.renewals.status Renewal schedule (read) low No dry run
ssl.resolver.flush Clear a server's DNS cache low

Permissions and limits

Permissions

  • ssl.cert.view View certificates
  • ssl.cert.issue Issue and renew ACME and self-signed certificates
  • ssl.cert.upload Upload custom certificates
  • ssl.cert.attach Attach certificates to hosts
  • ssl.cert.delete Delete certificates
  • ssl.cert.revoke Revoke certificates
  • ssl.csr.manage Generate CSRs
  • ssl.https.manage Force HTTPS
  • ssl.ca.manage Manage certificate authorities

Plan limits

  • ssl.custom_certs Uploaded certificates
  • ssl.acme_certs ACME certificates
  • ssl.wildcards Wildcard certificates
  • ssl.san_per_cert Names per certificate

Engineering notes

Generated from modules/ssl/docs.md at build 38156245. These are the notes the engineers keep next to the code: precise, technical, and honest about what is not done yet.

ACME order manager in the control-plane plugin on lego v4 (MIT) used as a library; spec docs/specs/ssl.md. Desired/observed state lives in schema m_ssl (cas, certs, cert_history): only public material.

Keys never leave the node (ADR 0012 §6)

The agent (internal/agent/ssl.go) generates the key (ECDSA P-256 default, P-384, RSA 2048/3072/4096) and returns a CSR; the plugin runs lego ObtainForCSR with it. The key waits in /var/lib/respirecloud/ssl/pending/<cert id>.key (0600) until the signed chain arrives, then ssl.cert.install checks the public keys match, promotes it to /var/lib/respirecloud/ssl/certs/<id>/{fullchain,privkey}.pem (previous kept as .prev) and deploys from disk to the targets:

  • web: calls the web driver's own webCertInstall in-process (same agent binary), so web's validate/swap/health/rollback path is used and the key never travels over the bus (web's web.sites.cert.install action would need it in params). The agent then systemctl reload nginx: the web driver does not reload when the rendered config is unchanged, so a renewal would otherwise keep serving the old certificate from memory (found in the lab).
  • mail: /etc/rc-mail/tls/{fullchain,privkey}.pem (the path mail's installer self-signs at), then reload of postfix and dovecot.
  • panel: /etc/respirecloud/tls/panel/{fullchain,privkey}.pem (no reload; core wiring is a follow-up). Errors, events, audit and API results never contain key material or raw CA text (sslx.Classify maps failures to plain words). Uploads (custom certs) are the one place a user-supplied key reaches the plugin as a param (redacted in the audit); it is forwarded to the agent and not stored in the database or returned.

Orders

ssl.cert.issue (dry-run plan) -> row pending -> runIssue: lease lock (10 min) -> CAs in order (pinned CA = no fallback; rate-limited CAs last; fall back on outage/rate-limit/CAA, not on validation failures) -> per-CA mutex (orders to one CA are serialised) -> CSR on node -> HTTP-01 (agent writes the token under /var/lib/rc-acme/.well-known/acme-challenge/, web serves it) or DNS-01 (dns.acme_challenge.set|clear as the system actor) -> ssl.cert.install on the node. The dns module writes the TXT in a zone on this panel, or, for a domain whose DNS lives at a provider (providers link in external mode), at that provider through providers.acme_challenge.set|clear: only the _acme-challenge TXT RRset is changed, its values are deduplicated (a retry adds nothing) and every other record of the zone is written back unchanged. Propagation: a zone on this panel answers at once (2 s fixed wait, no lookup); when any record goes to a provider, lego checks the zone's own nameservers until all of them answer with it (up to 5 minutes every 10 s, dnsProvider.Timeout, inside the 10-minute lease). Wildcards always use DNS-01. Before the order, wildcardReady asks dns.acme_challenge.check (a zone here, or a provider link whose key is accepted and shows the zone; read-only) and otherwise refuses with precondition_failed: a plain-words reason and details (code, steps, ask_owner). A team member (sub-user) cannot change connections or domain settings, so their steps are addressed to the account's owner. ssl.wildcard.check {names} gives the same answer before ordering (permission ssl.cert.view, so team members can ask; a name the asker may not order gets only that answer, nothing about its DNS). Without a dns module that has the check, the old rule applies (a zone hosted here, via dns.zone.get). Failure: row keeps the previous certificate active, renewal_state = waiting_dns | rate_limited | failed | deploy_failed, plain-words last_error, backoff 5 m / 15 m / 1 h / 3 h / 6 h (rate limit >= 1 h), event ssl.cert.failed. ssl.cert.renew (force) = "Retry now". If the CA issued but a target refused it, the chain is recorded and only the deploy is retried. ARI: after issuing, GetRenewalInfo -> a random instant inside the CA's suggested window becomes renew_at (ari=true, and the next order sends replaces); without ARI renew_at = notAfter - min(30 d, lifetime/3) (a 6-day cert renews on day 4).

Checked before every order (w12 card I, ADR 0036)

Owner, 2026-10-27: "always verify domains for SSL first on the server; once all is verified, do the calls to ACME and Let's Encrypt, so third parties don't rate-limit us"; "clear DNS all the time". runIssue calls checkOrder before any authority is contacted (before the account, the directory, the key):

  • the node's resolver caches are flushed (agent op ssl.resolver.flush: resolvectl flush-caches, unbound-control flush_zone ., nscd --invalidate=hosts, whichever runs);
  • HTTP-01: each name's A and AAAA on its own name servers (asked directly, aliases followed) and on the public resolvers; agent op ssl.selftest.http writes a random token under /var/lib/rc-acme/.well-known/acme-challenge/ and fetches it through every address (Host = the name, port 80, redirects like the authority); an address that does not return it is "not this server" (or port 80 closed when it is one of the node's own); public resolvers that still answer something else are "not propagated yet";
  • DNS-01: the zone's listed name servers (the public delegation) must all serve it authoritatively; for a zone on this panel a probe TXT (respirecloud-check-…) is written through dns.acme_challenge.set, must show on every one of them within 45 s, and is removed; during the order lego's propagation check is replaced by txtPrecheck: the authority is told to look only when every name server shows the record (a missing record is never a failed validation);
  • CAA (RFC 8659 climb, issuewild for wildcards, critical unknown tags) is judged per authority: a forbidden authority is skipped (the next may be allowed); its CAA names come from cas.caa_identities (the directory's caaIdentities, learned at add/test, else a well-known table, else the administrator);
  • the order budget (table orders): per registered domain 40 issued per 7 days, 4 identical, 3 failed validations per name per hour, 250 orders per 3 hours (setting order_budget); private authorities (an IP, .test/.internal/ .local directory) have none; staging is counted apart. Package modules/ssl/preflight asks the questions (miekg/dns, never the server's cache) and judges them into problems in plain words; checks.go adds the fix (problem.go, the ADR 0033 problem shape: dns.record.set to point a name here or allow the authority in CAA, dns.record.unset for a stray AAAA, ssl.cert.renew "Check again"). The problem is stored in certs.last_problem, rides in the job's error (details.problem) and in ssl.cert.failed. Resolvers: setting resolvers, else (every authority private) the server's own /etc/resolv.conf, else 1.1.1.1, 8.8.8.8, 9.9.9.9. server_addresses names public addresses behind NAT. ssl.cert.precheck runs the same checks without ordering (no probe record). Tests: preflight/fakedns is a DNS network in miniature.

Wildcard first (w12 card I)

Owner: "a proper wildcard with its cron and stuff, instead of making dozens of SSLs for everything, even the panel and email". With setting wildcard_first (default on), resolveIssue widens names to <zone> + *.<zone> when the panel writes the zone (dns.acme_challenge.check ready, here or at a provider) and the world asks that zone (zoneServed: the public delegation leads to the same apex and, for a zone here, lists one of its NS records). All names must qualify; a name deeper than one label stays as it is. An administrator's order without an account (mail, panel) belongs to the account that holds the zone, so its sites share the certificate. Before ordering, findCovering looks for a valid certificate of the account on the node that covers the names (not expiring within 7 days, renewal not failing) and attaches it (reused: true); exact: true orders exactly the names. Several hosts share one row (targets); supersede lets a shared certificate go of one site only; attaching a mail or panel host takes that target from the certificate that held it (dropped when nothing is left). ssl.cert.use_wildcard {domain|cert_id} (dry run plan names which certificate covers which host) moves every certificate of its own under the zone; the scheduler does the same at a certificate's renewal (renewIntoWildcard). Non-staff cannot delete or revoke a certificate that serves mail or the panel.

Choosing a certificate, consolidation, cleanup (fix/cert-picker)

Owner on s1, 2026-10-27: "it didn't auto pick SSL and there is no way I can select?" (choices.go).

  • ssl.cert.choices {site_id | target mail|panel + target_host | names + account_id} (read): every valid certificate that may serve the address, wildcards first, current (what serves it now) and suggested (the covering wildcard when the address has none or one of its own). Scope: a site only ever sees its own account's certificates; mail and panel addresses (administrators only) the server's own and those of the account that holds the domain. With names it returns sentence for a new site ("Uses the certificate for *.example.com (valid until …): nothing is ordered"). Auto-SSL attaches the same one (wildcard first, longest valid).
  • ssl.cert.usage {cert_id}: used_by and could_serve (covered sites of its account on its server, and covered mail/panel addresses of a domain its account holds). ssl.cert.use_for {cert_id, site_ids, hosts} attaches it to several in one step (dry run lists each address before and after; an address whose install fails keeps its own).
  • Consolidation: the scheduler runs consolidateDue once per issue of every account wildcard (marker: history kind consolidated): addresses it covers that have no certificate, or a single-name ACME certificate (sites of its account, mail and panel addresses of a domain it holds) move onto it through ssl.cert.attach. Uploaded certificates stay (a person chose them).
  • A certificate that loses its last address to another one (attach, consolidation) or by ssl.cert.detach is kept, stops renewing (auto_renew=false) and shows as unused (with covered_by) in ssl.cert.list; an order still waiting for its first issue is cancelled instead. Only ssl.cert.cleanup {cert_ids?} removes unused ones (previewed).
  • ssl.cert.detach {site_id | target + target_host, cert_id?} takes a certificate off one address (agent ssl.cert.remove with a fresh cert id, so only that address's files go). The mail module should call it as the system when a domain leaves its own mail host: ssl.cert.detach {target: "mail", target_host: "mail.<domain>"}.

Renewals made visible (w12 card I)

ssl.process_due writes table scheduler (last run, result); ssl.renewals.status returns it with the next renewals, the failing ones (with their problem) and the latest results (Renewals tab). ARI windows are asked again every 12 h for up to 5 certificates per run (ari_checked_at). After every install verifyServed asks each target which certificate it serves (web and panel hosts on 443, mail on 993) and reinstalls once when it still serves the old one (deploys[].served). The panel's own TLS listener reloads the files within 30 s by itself. The first failure of a renewal raises core.notice.raise (bell, the account too); the certificate in use stays. acme_staging sends orders to the staging twin (Let's Encrypt, Google; an authority without one is left out) with a staging account of its own. ssl.resolver.flush (admin, dry run) clears a server's caches; ssl.on_dns_changed does it after dns.record.changed, dns.zone.created|deleted. Every change has a dry run now (attach, upload, CSR, self-signed, HTTPS, app domain).

Auto-SSL (subscriptions, durable, idempotent)

  • web.site.created|updated (ssl.on_site_created|updated, one action per event: shared action names share a consumer): skips web's own certificate: installed update; keeps a cert already attached that covers every name; else attaches an active cert of the account that covers all names (e.g. a wildcard); else orders one cert for all names of the site and, when it is active, deletes older ACME certs of that site (alias added -> one combined cert, the site always has a certificate).
  • domains.created for alias|parked: web adds aliases without emitting web.site.updated, so ssl waits (fails, redelivered) until the site lists the alias and then runs the same check. For apex domains and setting auto_wildcard it orders apex + *.apex.
  • web.site.deleted strips the target (and deletes a non-wildcard ACME cert with no target left); domains.deleted stops renewal and deletes after 7 days (certs that only cover that domain); accounts.deleted removes the account's certs and node files.
  • Scheduler ssl.process_due (every 1 m, system): marks expired, emits ssl.cert.expiring at 14/7/3/1 days for certs whose renewal is failing, runs due renewals and due retries (25 per run), deletes after grace.

Actions

CA: ssl.ca.list|add|update|remove|test (admin, high risk; EAB HMAC and the ACME account key live in the host vault as ca_eab:<id> / ca_key:<id>; the account registers on first use). Certs: ssl.cert.issue|renew|delete|revoke (dry-run plans), ssl.cert.upload (PEM; key match, expiry, weak key, coverage, chain order reported; without a key it matches a pending CSR by public key), ssl.csr.create, ssl.selfsigned.create (flagged untrusted), ssl.cert.attach, ssl.cert.list|get, ssl.check (agent connects to 127.0.0.1:443 with SNI, reports the served cert and whether it verifies), ssl.https.set (calls web.sites.update force_https). Limits: ssl.wildcards (reserved per wildcard cert), ssl.custom_certs (per upload), ssl.san_per_cert (setting san_per_cert, default 100), ssl.acme_certs unlimited. Settings (core.settings scope module:ssl): node_id, email, key_type, auto_ssl (default true), auto_wildcard, san_per_cert. Events: ssl.cert.issued|renewed|failed|expiring|revoked, ssl.ca.ratelimited.

Contract for other modules

  • Any module may call ssl.cert.issue {hosts[], target: mail|panel|none, account_id?} (admin/system for mail/panel) and ssl.cert.attach {cert_id, target: mail|panel | site_id}; renewals redeploy to every recorded target automatically.
  • mail: installs/reloads at /etc/rc-mail/tls as above; mail should call ssl.cert.issue {hosts:[<mail hostname>], target:"mail"} after mail.install (not wired by this card). panel/core: target:"panel" writes /etc/respirecloud/tls/panel/; core must read it and reload (not wired).
  • web (requests): (1) has_certificate was false after install in the lab (the _cert layer row is not persisted), ssl does not rely on it; (2) emit web.site.updated when an alias is added/removed (ssl works around it via domains.created); (3) reload nginx when only a certificate file changed, or accept a cert_ref instead of key bytes in web.sites.cert.install.

Verified (lab w5-01, Ubuntu 24.04, Pebble as the CA, lego 4.35.2)

See docs/tasks/w5/w5-01-ssl.handover.md for the commands and outputs.

Not done / next

PKCS#12 upload; a lab run of a wildcard issued through a real external DNS provider (covered by a fake Cloudflare, modules/providers/cp/acme_provider_test.go, and in the lab by the Hostinger stand-in modules/ssl/hostingerfake, lab/tests/lab-ssl-certs.sh); ACME challenge delegation (_acme-challenge CNAME to a zone of this panel, so a domain's owner adds one record once instead of sharing a key); TLS policy (ssl.policy.set, min version/ciphers/OCSP stapling); (HSTS is built in the web module: header presets, http.hsts_max_age); shared-cert/LB key distribution (vault); CT monitor; on-demand TLS ssl.ondemand.ask; per-node deploy state for clusters (a cert is deployed on the one node that serves its site); shared certs losing a name when a domain is removed; a rate-limit dashboard (the order budget refuses, orders holds the counts, no screen yet); renewal notices to users before expiry (events, and the bell at the first failure).

The certificate card (UX round g3)

One card (ui/src/cert-card.tsx) shows which certificate serves an address and why, lets the person pick another from ssl.cert.choices (applied through ssl.cert.attach with its plan), "Where it is used" (ssl.cert.usage, "Stop using" = ssl.cert.detach, "Use it for more addresses" = ssl.cert.use_for), the always-HTTPS switch of a site (ssl.https.set), "Upload my own certificate" and the clean-up of certificates nothing uses (ssl.cert.cleanup, also at the top of the certificate list). It is used in a site's HTTPS topic, on the mail server page, on each panel address of Branding and, read only, in the summary of a new site. A certificate's row on the SSL page shows its Used by and more-addresses section.

Addresses of this panel (w14). Administrators see a card above the certificate list with each verified panel address (from Branding > Panel hostnames) and the certificate it serves, with the same "use another certificate" choice as a site.

Certificates for container stacks

ssl.cert.stack_resolve (internal, read only, system caller only) tells the containers module, for each host name a stack lists in x-rc-certs, whether the stack's account owns the name and which active ACME or custom certificate on the stack's server covers it (an exact name beats a wildcard, then the longest validity). Ownership is the issuing rule (checkOtherTenants) plus a positive check that the account holds the name or a parent of it; staff get no exception. The key itself never passes through the control plane: the agent copies it on the node. See the containers docs.