Skip to main content

SSL/TLS Certificates

Aegis manages SSL/TLS certificates for all proxy hosts. It supports three certificate sources: Let’s Encrypt (automatic ACME), Cloudflare Origin CA (API-integrated), and Custom (manual PEM upload). Private keys are encrypted at rest using AES-256-GCM.
Image

Certificate Sources


Let’s Encrypt (ACME)

Aegis uses Go’s autocert library to obtain and renew Let’s Encrypt certificates automatically via the ACME HTTP-01 challenge.

How It Works

  1. Set the proxy host’s SSL mode to letsencrypt in the admin UI
  2. Aegis validates that the domain is configured as a proxy host (host policy check)
  3. When a TLS handshake arrives for that domain, autocert requests a certificate from Let’s Encrypt
  4. The HTTP-01 challenge is served on port 80 (the HTTP proxy listener handles /.well-known/acme-challenge/ paths)
  5. The certificate is cached in the autocert cache directory (default .cache/ssl)
  6. Renewal happens automatically before expiration

Requirements

  • Port 80 must be reachable from the internet for HTTP-01 challenge validation
  • The domain must resolve to the Aegis server’s public IP
  • The proxy host must have ssl_mode set to letsencrypt

Configuration


Cloudflare Origin CA

Aegis can request Cloudflare Origin CA certificates directly through the Cloudflare API. This is ideal when Aegis sits behind Cloudflare’s proxy, where Let’s Encrypt HTTP-01 challenges may not reach the origin server.

How It Works

  1. Aegis generates a CSR (Certificate Signing Request) with the requested hostnames
  2. The CSR is submitted to Cloudflare’s Origin CA API (/client/v4/certificates)
  3. Cloudflare issues a signed certificate (valid up to 15 years)
  4. Aegis stores the certificate and encrypted private key in SQLite
  5. The certificate is loaded into the TLS configuration for SNI-based selection

Authentication Methods

Request Options

API Endpoint

Response:
The private key is generated locally, never sent to Cloudflare, and stored encrypted (AES-256-GCM) in SQLite.

Custom Certificate Upload

Upload any PEM-encoded certificate and private key pair through the admin UI or API.

API Endpoint

Validation

  • The certificate and key must form a valid X.509 key pair
  • The leaf certificate is parsed to extract the issuer, expiration, and subject
  • The private key is encrypted with AES-256-GCM before storage

Assigning Certificates to Hosts

Certificates are assigned to proxy hosts through the host configuration:

Let’s Encrypt

Set ssl_mode to letsencrypt on the proxy host. No certificate ID is needed — autocert handles issuance automatically.

Custom / Cloudflare Origin

Set ssl_mode to custom and either:
  • Inline PEM — provide ssl_cert_pem and ssl_key_pem directly in the host update (Aegis stores and encrypts them automatically)
  • Certificate ID — reference an existing certificate by ssl_cert_id

Cloudflare Edge Certificates

In addition to Origin CA certificates (which live on the origin server), Aegis can request Cloudflare Edge Certificates through the Cloudflare API. Edge certificates are served by Cloudflare’s edge network on behalf of your domain — useful when you need Cloudflare to provision and serve a publicly trusted certificate (e.g., for advanced certificate packs, custom hostnames, or alternative CAs).

API Endpoint

Options

Edge certificates are managed by Cloudflare — Aegis submits the order and returns the Cloudflare certificate ID and status. The actual certificate is served by Cloudflare’s edge, not stored locally.

Local Certificate Authority (Trust Bundle)

Aegis generates its own local Certificate Authority on first run. This CA is used to sign self-signed certificates for the admin UI and proxy fallback TLS. The CA is stored in the SSL cache directory alongside the certificates it issues.

CA Files

All self-signed certificates are issued by the local CA, so trusting the single CA certificate on your OS or browser automatically trusts all Aegis-generated certificates.

Why Trust the CA?

When you first access the Aegis admin UI at https://127.0.0.1:9443, your browser will show a certificate warning because the self-signed certificate is not trusted by default. You can either click through the warning each time, or trust the Aegis local CA once to permanently eliminate the warning. The same applies to the proxy fallback certificate — if a proxy host has no Let’s Encrypt or custom certificate configured, Aegis serves a self-signed certificate signed by the local CA.

Downloading the Trust Bundle

Aegis provides a downloadable trust bundle containing the CA certificate and installation instructions for every major platform:
This returns a ZIP file containing:

Installing the CA Certificate

macOS:
Windows:
Linux (Debian/Ubuntu):
Linux (RHEL/Fedora):
Browser (Firefox — uses its own trust store):
  1. Open Settings -> Privacy & Security -> Certificates -> View Certificates
  2. Import aegis-local-ca.crt under the Authorities tab
  3. Check “Trust this CA to identify websites”
After installation, the browser/OS will trust all certificates signed by the Aegis local CA without showing warnings.

Certificate Renewal

If a signed certificate is no longer issued by the current CA (e.g., the CA was regenerated), Aegis detects this and re-issues the certificate automatically.

SNI Certificate Selection

When a TLS handshake arrives, Aegis selects the certificate in this order:
  1. Host binding — if the proxy host has an ssl_cert_id, use that certificate
  2. Domain match — check all stored custom certificates for a domain match
  3. Autocert — attempt Let’s Encrypt certificate retrieval (for hosts with ssl_mode: letsencrypt)
  4. Self-signed fallback — generate a self-signed certificate covering all configured domains
This ensures every TLS connection receives a certificate, even if the preferred source is unavailable.

Private Key Encryption

All private keys are encrypted at rest using AES-256-GCM:
  • Key source — provided via AEGIS_SSL_KEY (64-char hex string) or auto-generated on first run
  • Auto-generated keys are stored in the SQLite settings table
  • Each key gets a unique random nonce (GCM nonce size)
  • Decryption happens only when loading certificates into memory at startup or after a reload

Certificate Lifecycle


Host SSL Settings

Each proxy host supports these SSL-related settings:

API Reference

Certificate Object