# Certificates from files on the machine

> Hand the control plane a certificate your provisioner manages as files, how renewals are followed, and how to take over from the Configuration page.

## When to use it

When a provisioner (Ansible, cloud-init, Terraform, a Vault agent, cert-manager on the host) already puts a certificate for this machine on its disk and renews it there, the control plane can use it for the user interface and the inference API, and keep following it. Without files, the control plane uses certificates from its own root CA (see **Trusting the control plane in your browser**), or one you upload on the Configuration page.

One certificate serves both: the control plane (port 3443) and the inference port (443), where the inference API and inference nodes connect. Inference nodes accept it when it names the addresses in their install command and comes from a certificate authority the machine trusts. A control plane on several machines presents this one certificate on every machine.

## What the files hold

- The certificate file: your server certificate, followed by its intermediate certificates, and the root unless it is a public certificate authority's (the usual `fullchain.pem`), PEM.
- The key file: the certificate's private key, PEM, without a passphrase. ECDSA P-256 or P-384, or RSA of 2048 bits or more.

The certificate must name every address clients and inference nodes use, as IP addresses for the addresses they dial by IP, including the address inference nodes use for each control-plane machine when it is chosen (at install with the setting `CONTROL_PLANE_ADDRESS`, or under **Configuration → Network → Inference node endpoints**) and the addresses in every inference node's install command, and stay valid for at least 7 more days. A machine's own network address, which the control plane detects when no address is chosen for that machine, is not required: a certificate that does not name it is accepted with a warning that names the machine and says inference nodes cannot connect to it through this certificate. An inference node checks it against the certificate authorities its machine trusts: a public certificate authority's certificate works as it is; one from your company's certificate authority needs that root installed on the inference node's machine.

## Installing with them

Name the two files as variables before `sh`:

```sh
curl -fsSL https://get.onprem.ai/control-plane | TLS_CERTIFICATE_FILE=/etc/pki/onprem-ai/fullchain.pem TLS_PRIVATE_KEY_FILE=/etc/pki/onprem-ai/privkey.pem sh
```

A new install writes the two variables as settings into `/etc/onprem-ai/control-plane/config.env`. The settings carry paths, never the content of the files. On a machine where the control plane is installed, a variable changes nothing: set `TLS_CERTIFICATE_FILE` and `TLS_PRIVATE_KEY_FILE` in `config.env`, then run `sudo onprem-ai-ctl install`. That run hands over the files the same way.

A machine that was installed before `config.env` existed has no such file, and its settings are in the generated files. From the moment `config.env` exists, it is the only source of the settings: a setting that it does not name gets its default. So when you create the file on such a machine, write into it every setting in effect that you want to keep. `sudo onprem-ai-ctl doctor` names the files that hold them.

The installer:

1. copies the two files into the control plane's data folder, `tls/certificate.pem` and `tls/private-key.pem` (on Linux `/var/lib/onprem-ai/control-plane/tls/`), owned by the control plane's user (uid 1000), mode 0400, in a folder mode 0700, and records the two paths it was given in `tls/source-paths.env`;
2. checks them the way an upload is checked, before the control plane starts serving. A certificate it cannot use stops the install with the reason and the fix, for example a key that does not belong to the certificate or an address the certificate does not name, so the control plane never starts on another certificate in place of yours.

### Behind a router or a DNS name

A machine reached through a router or a DNS name, with a certificate for that name (a wildcard such as `*.example.com`), has its own private network address, which no public certificate names. Name the address inference nodes use when you install:

```sh
curl -fsSL https://get.onprem.ai/control-plane | TLS_CERTIFICATE_FILE=/etc/pki/onprem-ai/fullchain.pem TLS_PRIVATE_KEY_FILE=/etc/pki/onprem-ai/privkey.pem API_GATEWAY_PUBLIC_BASE_URL=https://platform.example.com CONTROL_PLANE_ADDRESS=platform.example.com sh
```

`CONTROL_PLANE_ADDRESS` takes a hostname or an IP address. `API_GATEWAY_PUBLIC_BASE_URL` takes `https://` and that address, with `:<port>` when the inference port is not 443 (an IPv6 address in brackets); set `INFERENCE_PORT` to that port then. The control plane takes `API_GATEWAY_PUBLIC_BASE_URL` as the API gateway's public address when it starts for the first time, and `CONTROL_PLANE_ADDRESS` as this machine's address for inference nodes when this machine first registers; the installer checks that the certificate names it, and every inference node's install command names it. After that, the address inference nodes use for this machine changes under **Configuration → Network → Inference node endpoints**, and the API clients' address under **Configuration → Network → API Gateway endpoints**.

Every run of `sudo onprem-ai-ctl install` on a machine whose `config.env` names the files copies them again: running the install again is one way to hand over a renewed certificate. A run on a machine whose `config.env` names none leaves `tls/` as it is.

## Renewals

The control plane reads `tls/` every 30 seconds and takes a changed certificate into use within a minute, checked first. A provisioner that renews on the machine can therefore write straight into `tls/`, keeping the owner (uid 1000) and the mode (0400), for example by writing a new file and renaming it over the old one. A renewed certificate the control plane cannot use is not taken: the last good one stays in service, and the reason is in the log of the `edge-certificate-writer` service (`docker compose --project-name onprem-ai-control-plane logs edge-certificate-writer`), including "The control plane cannot read ..." when a file has the wrong owner or mode.

The control plane cannot renew the certificate itself. It raises an alert 30 days before it expires and again at 7 days.

## On the Configuration page

Under **Configuration → Security → Certificates, Public certificate**, the **Certificate source** of both surfaces reads **Installer files**: "Managed by the installer: this certificate follows the files given at install", with when they were last read. The page shows the source, not the files: to use other files, name them in `config.env` and run `sudo onprem-ai-ctl install`, as in "Installing with them" above. The info icon beside **Certificate source** explains each source and links to this guide.

**Taking over:** choosing **Built-in** or **Uploaded** stops using the installer's files for that surface. Renewals your provisioner writes are then ignored, and the card says so when the files change ("Installer files changed: ... not in use"). Running the installer again does not take the certificate back.

**Handing back:** choosing **Installer files** again reads the current files at once, checks them, and uses them for both surfaces. It is drawn always; it is unavailable, with the reason, when the control plane was installed without files.

Each change asks for your password and is recorded in the audit log.

A provisioner that prefers an API to files can upload instead, with a control plane access token, after the install: that certificate is an uploaded one, and the provisioner renews it by uploading again.
