# Certificates and trust

> Renew the workload certificates, replace the workload CA, trust the local certificate authority and add private CAs.

Source: https://docs.corfedo.ai/operate/single-host/certificates-and-trust/

An installation uses two kinds of certificates. The HTTPS certificate serves the workspace address and, with the bundled account service, `auth.<workspace address>`. Workload certificates are internal certificates that Corfedo's own services use to trust each other. You never give them to users.

## Workload certificates

Workload certificates expire after one year and do not renew on their own. Run `update` or `renew-certificates` before then, or the installation stops working. `status` shows the days left on each. Every `update`, also for the installed release, renews those that expire within 90 days. The workload CA in `generated/workload/` lasts ten years.

Renew them:

```sh
sh ~/corfedo/install.sh renew-certificates
```

It reissues the certificates, restarts Corfedo's services together and checks readiness. It needs no network access and also recovers an installation whose certificates have already expired.

**Check:** `status` shows about 365 days on each workload certificate and ends with `Ready.`

### Replace the workload CA

Before the CA expires, or if its key may be exposed:

1. Move `generated/workload` aside.
2. [Run `update` for the installed release](https://docs.corfedo.ai/operate/single-host/update/#apply-changed-settings). It creates a new CA and certificates.
3. Run `renew-certificates`, so every service restarts with the new certificates.

## HTTPS certificates

| Install choice | Certificate | Renewal |
| --- | --- | --- |
| This machine (`corfedo.localhost`) | Caddy's local certificate authority | Caddy renews it. Clients must trust the authority. |
| Public domain (`--tls acme`) | Let's Encrypt | Caddy renews it |
| Internal domain (`--tls files`) | Your certificate and key, copied to `generated/tls/site.crt` and `site.key` | Replace those two files and run `update` for the installed release, as [Apply changed settings](https://docs.corfedo.ai/operate/single-host/update/#apply-changed-settings) shows. Caddy loads the new pair, or keeps the previous one if the key does not match. |

## Trust the local certificate authority

With Caddy's local authority, every client of the two addresses must trust `generated/caddy-root.crt`. The installer prints these commands and never changes trust stores itself.

**macOS**

```sh
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/corfedo/generated/caddy-root.crt
```

**Linux**

```sh
sudo cp ~/corfedo/generated/caddy-root.crt /usr/local/share/ca-certificates/corfedo-local.crt && sudo update-ca-certificates
```

Firefox keeps its own store. Import the file under Settings › Privacy & Security › Certificates › View Certificates.

### Trust in clients

| Client | How it trusts the authority |
| --- | --- |
| .NET and Go programs on Linux, including the CLI | The system store |
| Node.js programs, including most coding agents | `NODE_EXTRA_CA_CERTS=~/corfedo/generated/caddy-root.crt` |
| Python programs | `SSL_CERT_FILE` or `REQUESTS_CA_BUNDLE` |

The platform's own containers already trust it.

## Trust private CAs

`--ca FILE` at install takes PEM certificates of private CAs Corfedo trusts in addition to public ones: the CA of your `--certificate`, or of an identity provider or reverse proxy with a private certificate. The installer keeps them in `generated/tls/ca.crt`. To change them later, edit that file and [run `update` for the installed release](https://docs.corfedo.ai/operate/single-host/update/#apply-changed-settings).

## Related

- [Reverse proxy](https://docs.corfedo.ai/operate/single-host/reverse-proxy/) serves the addresses with your own proxy.
- [Status and troubleshooting](https://docs.corfedo.ai/operate/single-host/troubleshooting/) shows certificate expiry.
