# Edge Configuration

The edge reads all of its configuration from environment variables at startup. Restart it after any change.

## Settings

| Variable | Set in production | Default | Description |
|---|---|---|---|
| `OCTET_URL` | Yes | A local address | The Octet API. Set it to `https://geo.octetproof.com`. If it is unset, the edge still starts, but every session fails with `502` `octet_unreachable`. |
| `LICENSE` | Yes | Unset | Your license token, `octet_live_v4.public....`. See [Credentials](/docs/browser/integration/credentials/). |
| `ALLOWED_ORIGIN` | Yes | `*` | The origins allowed to call the edge from a browser, comma-separated with no spaces, for example `https://www.example.com,https://app.example.com`. Applies to both the POST and the WebSocket. The default `*` allows any origin, so always set it in production. |
| `PORT` | Yes | `8080` | The TCP port to listen on. Use `443` in production. |
| `EDGE_TLS_CERT_FILE` | Yes | Unset | Path to your TLS certificate chain in PEM format, such as a Let's Encrypt `fullchain.pem`. |
| `EDGE_TLS_KEY_FILE` | Yes | Unset | Path to the matching private key in PEM format, such as `privkey.pem`. |
| `EDGE_DEBUG` | No | Off | `1` or `true` logs one line per request, including the end-user's IP address. Use it only for short diagnostic sessions, and never leave it on in production. |
| `EDGE_CLIENT_CERT_FILE` | Yes | Unset | Mutual TLS to Octet. Path to your edge's client certificate, downloaded from your license's **Edge configuration** tab in the Octet portal, under **Certificates**. |
| `EDGE_CLIENT_KEY_FILE` | Yes | Unset | Mutual TLS to Octet. Path to the client certificate's private key. |
| `EDGE_SIGNING_KEY` | Yes | Unset | The edge's signing key: a base64 32-byte Ed25519 key, from `openssl rand -base64 32`. The edge signs each session it forwards with it. Set only one of `EDGE_SIGNING_KEY`, `EDGE_SIGNING_KEY_FILE` and `EDGE_SIGNING_KMS`. If none is set, the edge forwards sessions unsigned and logs a warning at startup. See [Edge signature](#edge-signature). |
| `EDGE_SIGNING_KEY_FILE` | No | Unset | From v1.7.0. Path to a file holding the signing key, instead of `EDGE_SIGNING_KEY`, for example a systemd credential sealed to the host's TPM. See [Where to keep the signing key](#where-to-keep-the-signing-key). |
| `EDGE_SIGNING_KMS` | No | Unset | From v1.7.0. Sign in your cloud key service instead of on the host: `aws:<key ARN>` for AWS KMS or `gcp:<key version name>` for Google Cloud KMS. The key must be Ed25519. See [Where to keep the signing key](#where-to-keep-the-signing-key). |
| `EDGE_SIGNING_KID` | No | Derived from the public key | The signing key's ID, `kid`, which you register with the public key. Up to 64 letters, digits, `.`, `_` or `-`. The default is `edge-` followed by a hash of the public key. |
| `OCTET_CA_FILE` | No | Unset | Path to a CA certificate that Octet's server certificate must chain to. If it is unset, the edge checks Octet's server certificate against the host's system trust store. |

The edge serves HTTPS only when both `EDGE_TLS_CERT_FILE` and `EDGE_TLS_KEY_FILE` are set. Without them it serves plain HTTP, which browsers will refuse to use from an HTTPS page. It accepts TLS 1.2 and 1.3, with modern AEAD cipher suites only. From v1.6.0 it serves HTTP/2 to browsers that offer it, and HTTP/1.1 to the rest. There is nothing to configure. It loads the certificate at startup, so restart it after each renewal.

## Mutual TLS

The edge connects to Octet only over mutual TLS. It refuses to start if `EDGE_CLIENT_CERT_FILE` or `EDGE_CLIENT_KEY_FILE` is unset, or if `OCTET_URL` isn't `https://`. The one exception is an `OCTET_URL` on a loopback address, which is for local development. The log line names what is missing, for example `OCTET_URL must be https:// (mTLS to octet is required)`. To get the certificate, see [Deploy the Edge](/docs/browser/integration/deploy-edge/#4-install-the-client-certificate).

Octet's server certificate is a public certificate, so the edge verifies it with the host's system trust store. You don't need Octet's client CA certificate. Set `OCTET_CA_FILE` only if your security policy requires pinning Octet's server certificate to a specific CA.

The edge loads the client certificate and key at startup, so restart it after you renew them.

## Edge signature

With `EDGE_SIGNING_KEY` set, the edge signs each session it forwards to Octet. The signature covers the collection and everything the edge adds about the connection. At startup the edge logs the key's `kid` and public key:

```text
[octet-edge] S2 signing on: kid=edge-... ed25519 public key=... (register it in the licence portal)
```

Register both in your license's **Edge configuration** tab in the Octet portal, under **Signing keys**. If the value isn't a base64 32-byte key, the edge exits and logs `EDGE_SIGNING_KEY must be a base64 32-byte Ed25519 seed`.

Octet refuses a session whose signature fails its check. From v1.5.0, Octet also refuses an unsigned session, or one signed by a key that isn't registered for your license. The reason codes are in [Errors](/docs/browser/reference/errors/#reasons-octet-gives-your-edge). The signing key and the client certificate are separate credentials, and the edge needs both. See [Credentials](/docs/browser/integration/credentials/#register-an-edge-signing-key).

### Where to keep the signing key

Anyone who has the signing key can sign sessions for your license until you revoke it. From v1.7.0 the edge can read it from three places. Set only one:

| Setting | Where the key is | Use it for |
|---|---|---|
| `EDGE_SIGNING_KEY` | In the edge's environment file, in plain text | Development and tests |
| `EDGE_SIGNING_KEY_FILE` | In a file, for example a systemd credential encrypted to the host's TPM, which only the edge's service can read while it runs | Production edges. This is the recommended setting |
| `EDGE_SIGNING_KMS` | In AWS KMS or Google Cloud KMS. It never reaches the host | When your policy allows no private keys on hosts |

Keep the client certificate's key, `EDGE_CLIENT_KEY_FILE`, under the same protection as the signing key. Octet needs both, so protecting only one protects less than it seems. `EDGE_CLIENT_KEY_FILE` and `EDGE_TLS_KEY_FILE` are paths too, so they can be systemd credentials as well.

**A key sealed to the TPM.** This needs systemd 250 or later and a TPM 2.0. On cloud VMs that means a GCP Shielded VM, AWS NitroTPM or Azure Trusted Launch. The encrypted file can't be used on any other machine. As root on the edge host:

```bash
mkdir -p /etc/credstore.encrypted
openssl rand -base64 32 | systemd-creds encrypt --with-key=tpm2 --name=edge-s2-key - /etc/credstore.encrypted/edge-s2-key
```

Then remove the `EDGE_SIGNING_KEY=` line from the environment file, add this with `systemctl edit octet-edge`, and restart the edge:

```ini
[Service]
LoadCredentialEncrypted=edge-s2-key:/etc/credstore.encrypted/edge-s2-key
Environment=EDGE_SIGNING_KEY_FILE=edge-s2-key
```

The startup log shows `S2 signing on (file ...): kid=... ed25519 public key=...`. A new key needs registering in the portal. A TPM reset or a new VM means a new key. Don't run `systemd-creds decrypt` on the host, because it prints the key.

**A key in your cloud key service.** The edge uses the instance's own identity:

- **AWS KMS:** create an asymmetric key with key spec `ECC_NIST_EDWARDS25519` and usage `SIGN_VERIFY`, in the edge's region. Give the instance role `kms:Sign` and `kms:GetPublicKey` on it. Set `EDGE_SIGNING_KMS=aws:arn:aws:kms:<region>:<account>:key/<id>`.
- **Google Cloud KMS:** create a key with purpose `ASYMMETRIC_SIGN` and algorithm `EC_SIGN_ED25519`, in the edge's region. Give the VM's service account `roles/cloudkms.signerVerifier` on it. Set `EDGE_SIGNING_KMS=gcp:projects/<p>/locations/<l>/keyRings/<r>/cryptoKeys/<k>/cryptoKeyVersions/<n>`.

At startup the edge fetches the public key, checks that it is Ed25519 and that it may sign with it, and logs the `kid` and public key to register. Each session waits for one call to the key service, so keep the key in the edge's region. If a call fails or takes longer than 1 second, the edge answers the browser with `503` and `edge_signing_failed`, and sends nothing to Octet. It never forwards a session unsigned.

### Prove you hold the signing key

From v1.7.0 the Octet portal asks you to prove each signing key you register. In your license's **Edge configuration** tab, under **Signing keys**, select **Prove** next to the key. The portal shows a one-time challenge, valid for 30 minutes. On the edge host, with the same key settings as the running edge, run:

```bash
octet-edge prove-key --challenge <the challenge from the portal>
```

It prints one line. Paste it into the portal. The command doesn't start the edge. It refuses a challenge for another key, or one that has expired, and says why. Keys you registered before v1.7.0 can be proven the same way.

Today a key that isn't proven still works. Octet will refuse sessions signed with an unproven key from a date it announces in advance, so prove each key now.

## Testing only

The edge also reads two settings meant for testing. Leave both unset in production.

| Variable | Effect |
|---|---|
| `EDGE_EXPOSE_VERDICT` | `1` or `true` makes the edge answer the collector's POST with the verdict's `country`, `confidence` and `alarm` instead of `{"ok":true}`. The signed token is never included. |
| `EXIT_IP` | Replaces the user's IP address with this value for every session. It is for local tests where the browser reaches the edge over loopback. |

## Endpoints

| Method | Path | Called by | Response |
|---|---|---|---|
| `GET` | `/health` | You, for monitoring | `200` `{"ok":true,"role":"octet-edge"}`. Does not contact Octet. |
| `POST` | `/v1/signals` | The collector | `200` `{"ok":true}` when Octet accepted the session. Errors are in [Errors](/docs/browser/reference/errors/). |
| `GET` | `/v1/ws` | The collector | A WebSocket upgrade. It stays open for at most 15 seconds. |
| `OPTIONS` | `/v1/signals` | The browser, for CORS | `204` with the CORS headers. |

The edge serves every path at its root, so `apiUrl` is the edge's origin with no path, for example `https://octet.example.com`.

## Ports and connections

| Direction | Protocol and port | Peer |
|---|---|---|
| Inbound | TCP 443 | Browsers, for HTTPS and the WebSocket |
| Outbound | TCP 443 | `geo.octetproof.com` |

The edge must accept the browser's TCP connection directly. See [Deploy the Edge](/docs/browser/integration/deploy-edge/#nothing-may-terminate-tls-or-tcp-in-front-of-the-edge).

## Binaries

Each [release](https://github.com/octetproof/octet-browser/releases) contains static Linux binaries with no runtime dependencies:

| File | Platform |
|---|---|
| `octet-edge-linux-amd64` | Linux on x86-64 |
| `octet-edge-linux-arm64` | Linux on 64-bit ARM |

Check each binary against the release's `SHA256SUMS` before you install it. See [Deploy the Edge](/docs/browser/integration/deploy-edge/#1-download-and-verify-the-binary). The edge runs only on Linux.
