# Trusting your own certificate authority

> How the platform trusts your company's certificate authority, for example the one of a proxy that inspects TLS - through each machine's own trust store, which usually holds it already, or through the platform's folder for a certificate authority only the platform should trust.

## When you need it

You need this guide when one of these is true:

- A proxy on your network inspects TLS. It replaces every certificate with one from your company's certificate authority.
- A server the platform connects to has a certificate from your own certificate authority: an identity provider for single sign-on, a git server for catalogs, model storage, a container registry.

Behind a proxy server, the guide [Outbound proxy](/en/platform/docs/v5.10/guides/certificates-and-network/outbound-proxy/index.md) shows every step in order: what you set up, what the platform does, and how to check it.

## The machine's trust store: usually nothing to do

Every part of the platform trusts each machine's own trust store: the operating system's bundle of certificate authorities, with every one your company added to it. In most companies, the machine's template or configuration management adds the company's certificate authority there, because every other program on the machine needs it too. Then the platform trusts it with no step of yours.

To check it on a machine, before the install:

```sh
curl -sS -o /dev/null -w '%{http_code}\n' https://get.onprem.ai/platform
```

When the machine uses a proxy, run it with the proxy set (`export HTTPS_PROXY=http://proxy.example.com:3128`). An HTTP status of `200` or `3xx` means the machine trusts the certificate it got, also through a proxy that inspects TLS. `SSL certificate problem` means it does not: add the certificate authority to the machine's trust store.

RHEL, Rocky Linux and Fedora:

```sh
sudo cp corp-root-ca.pem /etc/pki/ca-trust/source/anchors/corp-root-ca.pem
sudo update-ca-trust
```

Debian and Ubuntu:

```sh
sudo cp corp-root-ca.pem /usr/local/share/ca-certificates/corp-root-ca.crt
sudo update-ca-certificates
```

Then restart what runs on the machine, so it reads the trust store again:

- Docker: `sudo systemctl restart docker`. This restarts the containers on that machine.
- The control plane: `sudo onprem-ai-ctl restart`
- The inference node: `sudo systemctl restart onprem-ai-inference-node`

Your certificate authorities are always added to the public ones. They never replace them. The platform never changes the machine's trust store: it only reads it.

## The folder: a certificate authority only the platform trusts

Each machine also has one folder of its own for the platform:

```text
/etc/onprem-ai/trusted-certificate-authorities/
```

Use it instead of the trust store in these cases:

- The certificate authority is for the platform only, for example the one of a private model registry, and the rest of the machine must not trust it.
- The machine's trust store must not be changed.
- The control plane runs on a Mac. A Mac keeps its trust store in the keychain, which the platform's containers cannot read. On a Mac, the folder is `/Users/Shared/onprem-ai/trusted-certificate-authorities/`.

Each machine trusts only its own trust store and its own folder. The control plane never sends its folder to the inference nodes. Machines in different networks can need different certificate authorities.

| Part | Trusts | When a change takes effect |
|---|---|---|
| The one-line installer | The machine's trust store and the folder | At the next install |
| The control plane | The public certificate authorities, the machine's trust store and the folder: for the license check, software updates, model storage, single sign-on, git catalogs and the proxy | After `sudo onprem-ai-ctl restart` |
| The inference node | The machine's trust store and the folder: for the control plane, model downloads, software updates and the proxy | After `sudo systemctl restart onprem-ai-inference-node` |
| Image downloads | The machine's trust store (Docker and Podman read it), and the folder through the files the platform writes for each registry | The trust store after a restart of Docker; the folder at the next image download |
| Each browser | Its own computer's trust store | Not covered: see the section **Browsers** |

### Add a certificate authority to the folder

On each machine that needs it:

```sh
sudo install -d -m 0755 /etc/onprem-ai/trusted-certificate-authorities
sudo cp corp-root-ca.pem /etc/onprem-ai/trusted-certificate-authorities/
sudo chmod 0644 /etc/onprem-ai/trusted-certificate-authorities/corp-root-ca.pem
```

Then restart what runs on the machine:

- The control plane: `sudo onprem-ai-ctl restart`
- The inference node: `sudo systemctl restart onprem-ai-inference-node`

The install of the control plane and the install of the inference node create the folder when it does not exist.

- Get the certificate authority's certificate from your network team. Ask for the root certificate, in PEM format. A PEM file starts with `-----BEGIN CERTIFICATE-----`.
- To convert a DER file to PEM: `openssl x509 -inform der -in corp-root-ca.der -out corp-root-ca.pem`
- One file can hold several certificates, for example a root and an intermediate.

### The rules for the files

- Only files that end in `.pem` or `.crt` are read. A file whose name starts with a dot is skipped. Every other file is shown as ignored.
- A file must hold at least one PEM certificate, and every certificate in it must be complete.
- The folder must not be writable by the group or by other users. Use mode `0755`. If the group or other users can write the folder, no file in it is trusted.
- A file must not be writable by the group or by other users. Use mode `0644`.
- A file must have the same owner as the folder. The install creates the folder for `root`, so the files must be root's too. `sudo cp` does this.
- A file must be a real file. A link in the folder is not followed: copy the certificate file itself into the folder.
- A file must not be larger than 1 MiB.

A file that breaks a rule is shown with its reason. The other files are still trusted.

To keep the files in another place, put a link or a bind mount at the folder's path. The folder itself can be a link. The files in it cannot.

## The control plane

The control plane reads the machine's trust store and the folder at start only. A change to either takes effect after `sudo onprem-ai-ctl restart`.

Each start writes the machine's trust store, with the number of certificate authorities in it, and the trusted files of the folder to the log of the service `trusted-certificate-authorities-bundle-writer`. To read it: `cd /opt/onprem-ai/control-plane && sudo docker compose logs trusted-certificate-authorities-bundle-writer`

Check the result:

- **Configuration → Security → Certificates**, section **Trusted certificate authorities**. It shows each certificate with its file, subject and expiry date. It says **Restart to apply** when the folder changed after the last start.
- `sudo onprem-ai-ctl doctor` shows the same list, and the machine's trust store with the number of certificate authorities in it.

The card lists the folder's certificates. The certificate authorities of the machine's trust store are trusted too, and are not listed one by one.

A file the control plane cannot use is shown with its reason in the same section, and an error report is written for it. The other files are still trusted.

The card shows the folder of the control plane's machine only. To see what an inference node machine trusts, run `sudo onprem-ai-node doctor` on that machine.

## The inference node

The inference node reads its own machine's trust store and folder at start. It trusts their certificate authorities on every connection it opens: to the control plane, for model downloads, for software updates, and through the proxy. A change takes effect after:

```sh
sudo systemctl restart onprem-ai-inference-node
```

Check the result: `sudo onprem-ai-node doctor` lists the folder's trusted certificates, with file, subject and expiry date, and every refused file with its reason.

The connection between an inference node and the control plane carries a second encrypted connection inside it. A proxy that inspects TLS can pass it on but cannot read it. More: the guide [Outbound proxy](/en/platform/docs/v5.10/guides/certificates-and-network/outbound-proxy/index.md), section How the connection to the control plane passes the proxy.

## Image downloads

Docker or Podman downloads the container images itself. It trusts the machine's trust store on its own, after a restart of Docker. For the certificates of the folder, the platform writes one file per registry, and writes it again before each download:

- Docker: `/etc/docker/certs.d/<registry>/onprem-ai-trusted-certificate-authorities.crt`
- Podman: `/etc/containers/certs.d/<registry>/onprem-ai-trusted-certificate-authorities.crt`

Docker and Podman read these files at each download. They need no restart. When the folder holds no usable certificate, the platform removes its files. The platform never changes or removes a file that it did not write.

- On the control plane's machine, `onprem-ai-ctl` writes the files before each download: `install`, `update`, `start` and `restart`. An update that you start in the control plane's pages uses the files of the last `onprem-ai-ctl` run. When an update needs a registry that the machine has no file for, run `sudo onprem-ai-ctl update` on the machine.
- On an inference node machine, the platform writes the file for an image's registry before each image download.

### Docker Hub on Docker

Docker never reads `certs.d` for Docker Hub (`docker.io`). It uses only the machine's trust store for it. Seven images of the control plane come from Docker Hub, and so do some model images. A certificate authority in the folder only does not cover them on Docker: put it into the machine's trust store, as the section **The machine's trust store** shows, and restart Docker. Podman reads `certs.d` for Docker Hub too.

## Browsers

The browsers trust their computer's trust store, or their own one. Neither the machine's trust store nor the folder changes it. The guide **Trusting the control plane in your browser** shows the steps for Windows, macOS, Linux and Firefox. Company computers often have your certificate authority already.

## When it does not work

```text
<destination> presents a certificate this control plane does not trust.
Cause:   certificate verify failed: unable to get local issuer certificate
Fix:     1. Copy that certificate authority's PEM file into /etc/onprem-ai/trusted-certificate-authorities/ on the control plane's machine
         2. sudo onprem-ai-ctl restart
```

| Symptom | Cause | Fix |
|---|---|---|
| The file shows under **Unusable files**: "holds no PEM certificate" | The file is DER, not PEM | Convert it: `sudo openssl x509 -inform der -in <file> -out <file>.pem`. Remove the original file. Restart. |
| The file shows under **Unusable files**: "cannot be read" | The control plane cannot read the file | `sudo chmod 0644 <file>`. Restart. |
| The file shows under **Unusable files**: "is writable by other users" | The group or other users can write the file | `sudo chmod 0644 <file>`. Restart. |
| The file shows under **Unusable files**: "belongs to another user than the folder" | The file's owner is not the folder's owner | `sudo chown --reference=/etc/onprem-ai/trusted-certificate-authorities/ <file>`. Restart. |
| The file shows under **Unusable files**: "is not a regular file" | The file is a link or a folder | Copy the certificate file itself: `sudo cp --remove-destination <the PEM file> <file>`. Restart. |
| No certificate is trusted, and an error report says the folder "is writable by other users" | The group or other users can write the folder | `sudo chmod 0755 /etc/onprem-ai/trusted-certificate-authorities/`. Restart. |
| The certificate shows **Added, restart to apply** | The control plane has not restarted since you added it | `sudo onprem-ai-ctl restart` |
| The certificate is trusted, but the error stays | The certificate is not the one the proxy or server uses | Ask your network team for the root certificate of the chain. `openssl s_client -connect <host>:443 -showcerts` shows the chain the server sends. |
| An inference node cannot connect, the control plane can | The inference node machine's trust store and folder do not hold the certificate authority, or the node did not restart | Add it to that machine's trust store (or its folder). `sudo systemctl restart onprem-ai-inference-node`. `sudo onprem-ai-node doctor` shows what the node trusts. |
| The install stops at "Downloading the images" with a certificate error from `platform.registry.onprem.ai` | Neither the machine's trust store nor the folder held the certificate authority when the install started, or Docker did not restart after the trust store changed | Add it to the trust store and restart Docker, or copy it into the folder. Run the install again. |
| The install stops at "Downloading the images" with a certificate error from `docker.io` | Docker does not read `certs.d` for Docker Hub | Add the certificate authority to the machine's trust store. `sudo systemctl restart docker`. Run the install again. See the section **Docker Hub on Docker**. |
