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.
Certificate Sources
Let’s Encrypt (ACME)
Aegis uses Go’sautocert library to obtain and renew Let’s Encrypt certificates automatically via the ACME HTTP-01 challenge.
How It Works
- Set the proxy host’s SSL mode to
letsencryptin the admin UI - Aegis validates that the domain is configured as a proxy host (host policy check)
- When a TLS handshake arrives for that domain,
autocertrequests a certificate from Let’s Encrypt - The HTTP-01 challenge is served on port 80 (the HTTP proxy listener handles
/.well-known/acme-challenge/paths) - The certificate is cached in the autocert cache directory (default
.cache/ssl) - 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_modeset toletsencrypt
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
- Aegis generates a CSR (Certificate Signing Request) with the requested hostnames
- The CSR is submitted to Cloudflare’s Origin CA API (
/client/v4/certificates) - Cloudflare issues a signed certificate (valid up to 15 years)
- Aegis stores the certificate and encrypted private key in SQLite
- The certificate is loaded into the TLS configuration for SNI-based selection
Authentication Methods
Request Options
API Endpoint
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
Setssl_mode to letsencrypt on the proxy host. No certificate ID is needed — autocert handles issuance automatically.
Custom / Cloudflare Origin
Setssl_mode to custom and either:
- Inline PEM — provide
ssl_cert_pemandssl_key_pemdirectly 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 athttps://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:Installing the CA Certificate
macOS:- Open Settings -> Privacy & Security -> Certificates -> View Certificates
- Import
aegis-local-ca.crtunder the Authorities tab - Check “Trust this CA to identify websites”
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:- Host binding — if the proxy host has an
ssl_cert_id, use that certificate - Domain match — check all stored custom certificates for a domain match
- Autocert — attempt Let’s Encrypt certificate retrieval (for hosts with
ssl_mode: letsencrypt) - Self-signed fallback — generate a self-signed certificate covering all configured domains
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
settingstable - Each key gets a unique random nonce (GCM nonce size)
- Decryption happens only when loading certificates into memory at startup or after a reload

