Skip to main content

Manage CAP's own TLS certificate

CertAutoPilot ships with a self-signed certificate so the web UI is reachable over HTTPS on first boot (browsers will warn — that is expected). Once the platform is running you can have CertAutoPilot manage its own TLS: issue a real certificate for the controller's hostname, distribute it to the node(s) that serve the UI, and let the normal renewal machinery keep it fresh. No extra software and no product feature to enable — this is the ordinary SSH distribution flow pointed at CertAutoPilot's own hosts.

This works identically on a single host and a multi-node cluster — you simply list every node as a target.

Where the served certificate lives​

On a standalone install, nginx terminates TLS and reads its certificate and key from:

/etc/certautopilot/tls/server.crt (root:root, mode 0644) — leaf + chain (fullchain)
/etc/certautopilot/tls/server.key (root:root, mode 0600) — private key

The backend itself listens as plain HTTP on 127.0.0.1; nginx is the only TLS terminator. Replacing these two files and reloading nginx swaps the served certificate without restarting the backend.

Other topologies
  • Kubernetes / Helm: the served certificate is not on disk — it is the <release>-tls Kubernetes Secret (type kubernetes.io/tls), consumed by both the backend and the frontend pods. Use cert-manager (the idiomatic K8s option) or the Kubernetes distribution module to write that Secret instead of the SSH recipe below.
  • Docker Compose: the shipped compose runs plain HTTP (dev only) — there is no TLS to manage.
  • CertAutoPilot OS (the appliance): the same two files, but written through the appliance's own import helper — see CertAutoPilot OS.

Recipe (SSH distribution)​

Prerequisites:

  • A certificate whose SAN covers the controller's public hostname (e.g. cap.example.com), issued from any CA you have configured, with auto-renew ON.
  • Root SSH access to every node (or a user with password-less sudo). Writing to /etc/certautopilot/tls, setting root:root ownership, and running systemctl reload nginx all require privilege. Key-based SSH as root is the simplest.
  • For the first certificate you need a working ACME challenge path — HTTP-01 (port 80 reachable to the controller) or DNS-01. Until that first certificate is issued and distributed, the self-signed one stays in place.

Steps (all in Settings → Distribution):

  1. Targets — add one SSH target per node (the two cluster IPs, e.g. cap-a and cap-b), or add both to a target group. A node distributing to itself over SSH is fine — no special handling needed.

  2. Path set — map the certificate artifacts to the exact paths nginx reads. This is a PathSet; the important columns are source, path, owner, and mode:

    fullchain /etc/certautopilot/tls/server.crt root:root 0644
    private_key /etc/certautopilot/tls/server.key root:root 0600

    Use fullchain (leaf + intermediates) for server.crt so clients get the full chain, and private_key for server.key at mode 0600. These match exactly what the installer's self-signed generator produced, so nginx needs no config change.

  3. Action set — reload nginx after the files are written. This is an ActionSet:

    sudo nginx -t
    sudo systemctl reload nginx

    nginx -t fails fast on a bad config before the reload. By default the action runs only when a written file actually changed, so a no-op redistribute won't reload.

  4. Module config + link — create an SSH module config referencing the target(s)/group, then link a distribution on the certificate to it.

That is all. On every renewal CertAutoPilot re-distributes automatically (the finalize step marks the distribution pending and enqueues it), so each node receives the new certificate and reloads nginx with zero manual steps.

Cluster notes​

  • The distribution job is picked up by whichever node's worker is free and it SSHes out to every listed target, so all nodes get the certificate regardless of which node ran the job — including the node CertAutoPilot itself runs on.
  • Because the source of truth is the issued certificate (stored once in the shared database) and each node is an explicit SSH target, adding a third node is just adding a third target — nothing else changes.
  • Prefer a target group over individual targets so a new node joins by group membership and inherits the same path set / action set automatically.

CertAutoPilot OS (the appliance)​

The appliance serves the UI from the same two files, but the recipe above does not fit it:

  • SSH accepts only the admin account (no root login), and admin can neither write /etc/certautopilot/tls nor reload nginx.
  • The cluster agent keeps a certificate there only when it was imported through the appliance; otherwise it re-issues its self-signed one when the node's names change and 30 days before it ends.

A distribution therefore goes through the appliance's import helper, the one behind the console's import tls-cert. CertAutoPilot writes the certificate and key into admin's home over SSH and runs the helper with sudo; admin may run it without a password. The helper:

  1. checks that the key matches the certificate and that the certificate is valid now;
  2. installs both for nginx (root, 0644 / 0600), keeps the previous pair beside them, and marks the pair as imported, so the agent keeps it across reboots, VIP changes and re-renders;
  3. reloads nginx after nginx -t; when nginx refuses the pair, puts the previous one back and fails the action.

Steps:

  1. SSH key. Make a key pair without a passphrase for CertAutoPilot, for example ssh-keygen -t ed25519 -N '' -f cap-dist. On the console of every node: set ssh-key <the line in cap-dist.pub>. If set ssh allow limits SSH, its list must include the nodes' own addresses: the distribution runs on whichever node's worker picks it up.

  2. Credential — type SSH private key, the contents of cap-dist.

  3. Path set (Linux) — leave owner empty: the files must stay admin's for the helper to take them.

    fullchain /home/admin/cap-tls/server.crt 0644
    private_key /home/admin/cap-tls/server.key 0600
  4. Action set — one command:

    sudo /usr/lib/cap/cap-import tls-cert /home/admin/cap-tls/server.crt /home/admin/cap-tls/server.key

    admin may run the helper only on files under /home/admin (or /tmp), so keep the files there.

  5. Targets — one SSH target per node: the node's management address, user admin, the credential, the path set and the action set above, host-key verification on (the key is pinned on the first run). Put them in a target group.

  6. Module config + link — an SSH module config on the group, linked to the certificate.

The certificate must name what browsers open: the VIP (its address or DNS name) and, when users reach nodes directly, the nodes' names or addresses. For ACME over HTTP-01 the appliance must answer on port 80, which it keeps closed: firewall http-01 enable on every node opens it for challenges only. DNS-01 needs nothing on the appliance. Until the first certificate is distributed, the self-signed one stays in place.

Afterwards show health on each node lists web UI certificate (imported) valid until <date>, and every renewal runs the distribution again. A node that joins later needs set ssh-key on its console and a target in the group.

What the credential can do
  • The credential logs in as admin, the console's account. Over a non-interactive SSH session that account gets a shell (file transfer and commands need one), so whoever may use the credential in CertAutoPilot can run commands as admin on every node. Give it to the people who administer the appliance only (resource grants).
  • A copy of the private key stays in /home/admin/cap-tls (mode 0600, owned by admin).
  • Without a licence CertAutoPilot holds one target at a time (target limit): enough for one node, not for a cluster.

Verifying​

After the first distribution:

# On each node
openssl x509 -in /etc/certautopilot/tls/server.crt -noout -subject -enddate
# From a client
echo | openssl s_client -connect cap.example.com:443 -servername cap.example.com 2>/dev/null \
| openssl x509 -noout -issuer -enddate

The distribution's status in the UI shows per-target success; a failed reload marks that target failed (and, if auto-rollback is enabled, a rollback re-deploys the previous retained certificate version through the same paths).

See also​