Configuration
The server reads an optional ferritor.toml in its working directory,
overridden by FERRITOR_* environment variables (nested keys with __, e.g.
FERRITOR_TLS__CERT). Policies can only come from ferritor.toml. It
takes no arguments: --version and --help print and exit, and any other
is refused (exit code 2) before anything is read, rather than ignored.
ferritor.example.toml documents every setting with its default: copy it
to ferritor.toml (gitignored) and edit. As shipped it’s a dev-mode config;
uncommenting [tls], the [[policy]] entries, audit_signing_key and
audit_file together makes it secured. A test loads it in both forms, so it stays
accurate.
In production you need only this file and/or the FERRITOR_* variables. The
.env file is for development, and only a debug build of the server
loads it (dotenvy searches the working directory and then every parent
directory for one, so a release build could otherwise pick up another
application’s .env). Its KEYS_DATABASE_URL/DATA_DATABASE_URL are for
the build and the tests (see development), not the
server.
Two modes, nothing in between
Section titled “Two modes, nothing in between”| dev | secured | |
|---|---|---|
| Configured by | no [tls], no [[policy]] |
[tls], at least one [[policy]], audit_signing_key, and audit_file or [audit_otlp] |
| Transport | plaintext | TLS, client certificate required |
| Authorization | everyone may do everything | the policy |
| Listens on | loopback only | any address |
| Audit log | chained, signed only with audit_signing_key; on stdout unless audit_file or [audit_otlp] |
chained and signed, in audit_file, at [audit_otlp]’s collector, or both |
| The server’s log | stderr | stderr |
Anything in between (TLS without a policy, a policy without TLS, secured
without a signing key, or with nowhere for the audit log) refuses to start. Dev mode is for trying ferritor out
and for development: anyone who can reach it can seal it, rotate, start a
rekey or submit fake shares, and real shares cross it in plaintext. Plaintext
serving also answers only requests addressed to localhost or a loopback
IP (421 otherwise), since listening on loopback alone doesn’t stop DNS
rebinding from a browser on the same machine.
Settings
Section titled “Settings”| Key | Default | |
|---|---|---|
listen_addr |
127.0.0.1:7070 |
gRPC and the JSON API, one port. Loopback only in dev mode. |
keys_database_url |
(required) | The keys database. |
data_database_url |
(required) | The data database. |
keys_database_max_connections, data_database_max_connections |
10 each | The most connections each pool opens (at least 1). A put holds a data-database connection for its whole transaction, so the data pool caps the writes in flight; past it, requests wait for a connection, up to database_timeout_ms, then UNAVAILABLE. Every server opens its own pools: keep the sum over all servers below Postgres’s max_connections (100 by default). |
database_timeout_ms |
5000 | Upper bound on any one database call (client side), the pool’s acquire timeout and Postgres’s statement_timeout. |
lock_timeout_ms |
2000 | How long to wait for a lock another transaction holds (a put to the same path, an unconfirmed rekey commit, a KEK floor raise). Must be above 0 and below database_timeout_ms. |
purge_deleted_after_days |
30 | How long a deleted version can still be restored before purge may remove it. Past it, the next purge removes it: the servers run one every purge_interval_minutes, unless every one is sealed, the purge is paused, or its runs fail. 0 warns at startup. |
max_versions |
10 | Live versions kept per path; each put marks older ones deleted. 0 keeps all. |
keyring_refresh_secs |
60 | How often an unsealed server reloads its KEKs, to follow rotations by other servers. 0 turns the periodic refresh off. |
policy_refresh_secs |
5 | How often an unsealed server checks whether the stored policies changed (one tiny read), reloading them if so: the longest a change through another server takes to reach this one. 0 turns the poll off. (Separately, every server re-reads and re-verifies the whole set once a minute, on its own schedule.) |
shutdown_delay_secs |
0 | On the first SIGINT/SIGTERM, how long to keep serving while reporting not ready before draining (at most 300). See operations. |
rotation_max_age_days |
90 | Rotation reminders: how many days a secret with the rotation flag (ferritor.rotation=true, see secrets) may go without a new version, counted from its current version’s creation. A reminder only: nothing is refused for age. 1 to 3650. |
kek_max_age_days |
365 | How many days a namespace’s active KEK may live before a rotation is due. 1 to 3650. |
root_key_max_age_days |
365 | How many days the root key may go without a rekey (which needs the share holders). 1 to 3650. |
rotation_warn_days |
14 | How many days before its maximum something counts as due soon: 1 to 3650, and below the shortest of the three maximums. |
purge_interval_minutes |
1440 | Scheduled tasks (operations): how often purge runs, removing deleted versions past purge_deleted_after_days. 1 to 43200. Every server shares one schedule, through the data database: a task runs once per interval, on whichever server claims it, which sets the next due time from its own setting, so keep it alike on every server. |
rewrap_interval_minutes |
60 | How often rewrap runs, moving DEKs to each namespace’s active KEK and retiring the KEK versions no row uses any more. 1 to 43200. |
audit_signing_key |
(secured: required) | Ed25519 private key, PKCS#8 PEM, signing the audit log’s checkpoints. Startup warns if group or others can read it. |
audit_file |
(secured: it or [audit_otlp]; dev: stdout) |
The file the audit log is appended to, created 0600 (startup warns if an existing one is readable by group or others). Reopened on SIGHUP, for rotation (audit log). The server won’t start if it can’t open it, and refuses requests while it can’t write to it. |
audit_file_max_bytes |
(unset: no rotation by size) | Rotate audit_file once it holds this many bytes (at least 1 MiB): renamed <audit_file>.1, older ones moving up, a new file started, each holding whole chains. For where nothing else rotates it (a pod). |
audit_file_keep |
5 | With audit_file_max_bytes: rotated files kept, 1 to 1000; the oldest is dropped. The file takes at most about (audit_file_keep + 1) × audit_file_max_bytes. |
[audit_otlp] |
(secured: it or audit_file) |
The audit log to an OpenTelemetry collector, OTLP log records over gRPC: endpoint (https://, or http:// on loopback), optional ca, cert and key (PEM; cert and key together). An entry counts as recorded once the collector has acknowledged it; one that’s down refuses requests (audit log). Read at startup. |
[tls] (secured mode):
| Key | Default | |
|---|---|---|
cert, key |
(required) | The server’s certificate chain and key (PEM). |
client_ca |
(required) | The CAs (PEM) whose client certificates are accepted. List only the CAs that issue client certificates. |
crl |
(none) | One PEM file with a CRL from each client CA. Without it no certificate can be revoked. See TLS. |
max_connection_age_secs |
3600 | Connections are recycled after this long (hygiene; expiry is enforced per request regardless). |
connection_age_grace_secs |
30 | How long a connection past its age may finish in-flight calls. |
[rate_limit] (both modes; see operations for
sizing and what each limit answers):
| Key | Default | |
|---|---|---|
server_max_in_flight |
2 × data_database_max_connections + 16 |
Calls running at once on this server, all callers together (at least 1). One over it waits for a slot, up to database_timeout_ms, then UNAVAILABLE; a client that leaves while waiting takes its call with it. Read at startup only. |
max_in_flight |
max(1, server_max_in_flight / 4) |
Calls running at once per identity; one more is refused (RATE_LIMITED). 0: no limit. |
requests_per_second |
0 | Requests per second per identity, with burst at once above it; over it, refused with when to retry. 0: no rate limit; at most 1,000,000. |
burst |
twice the rate | Only with a rate (at least 1). |
max_watch_streams |
256 | Watch streams open at once per identity (they last as long as their clients, so they aren’t calls in flight); one more is refused (WATCH_FULL, limit: identity). 0: no limit but the server’s 4,096; at most 4,096. Raise it for an identity many replicas share, each with a stream. |
[[rate_limit.identity]]: an identity’s own limits, taking priority over the
default: identity (exact, or a prefix by whole segments, like policy
paths; the most specific entry wins, and each identity under a prefix has
counters of its own), and any of max_in_flight, requests_per_second,
burst, max_watch_streams; a field left out is the default’s (an entry with its own rate but
no burst gets twice its rate). No max_in_flight may be above
server_max_in_flight, and an identity may be listed once.
Always on, not configurable: per identity, 10 denied requests a second (a burst of 50); and per certificate that names no caller (each request with one is refused and audited), 1 a second (a burst of 5), past which its requests are refused without an audit entry. Every limit is per server (operations). Admin calls the config rules allow are never limited, so an operator can always seal; requests in dev mode have no identity, so only the server-wide cap applies to them.
[identity] (secured mode only; see workload identity):
short-lived client certificates in exchange for a platform’s tokens.
| Key | Default | |
|---|---|---|
listen_addr |
(required) | The exchange’s own listener (TLS with the server’s certificate, no client certificate asked); not listen_addr’s. Read at startup only. |
lifetime_secs |
3600 | How long an issued certificate lives, 60 to 86,400, never past its token’s exp (a login issuer’s may be). The issuers’ default; each may set its own. Read at startup only. |
[[identity.issuer]], one trusted token issuer (at least one):
| Key | Default | |
|---|---|---|
name |
(required) | One path segment: the first segment of every identity it maps to, reserved for it (no [[policy]] may name an identity under it, unless it’s a login issuer). Unique. |
issuer |
(required) | Its tokens’ iss, exactly. Unique. |
audience |
(required) | What their aud must contain. |
jwks_file, jwks_url |
(one required) | Its public keys (a JWKS): a file, or an https:// URL fetched every 10 minutes. |
jwks_ca |
public web PKI roots | With jwks_url only: the CA (PEM) to verify it with. |
max_token_age_secs |
86400 | The oldest token accepted, by iat: 1 to 31 days. |
exchange_burst |
10 | Exchanges per identity at once, refilled at one a second: 1 to 10,000. Raise it to a deployment’s replica count when many share an identity and start together (workload identity). |
not_before |
(none) | RFC 3339: refuse its certificates issued before this. |
login |
false | People signing in (ferritor login --oidc), not workloads: [[policy]] rules may name its identities, admin actions included, and its certificates live lifetime_secs even past the token’s exp. |
lifetime_secs |
[identity]’s, 7200 for login |
How long its certificates live, 60 to 86,400. |
[[identity.issuer.map]], at least one per issuer, in order (the first
whose require holds decides): identity, a template starting with the
issuer’s name and /, with {claim} placeholders that each fill a
whole segment (/ or the end on both sides); require, a list of { claim = "…", one_of = ["…"] },
each claim text or a list of texts (a person’s groups: any item may be one of them), each claim at most once.
[[identity.revoke]]: identity (under a configured issuer) and
not_before (RFC 3339): its certificates issued before are refused.
[seal]: how the root key is opened at start (see
key management). Read at startup only;
switching providers takes a rekey.
| Key | Default | |
|---|---|---|
provider |
shamir |
shamir: the operators’ shares unseal every server after every start. awskms or gcpkms: a server unseals itself through AWS KMS or Google Cloud KMS (the shares stay the recovery shares); needs that provider’s section ([seal.awskms], [seal.gcpkms]) and no other’s, and a build with its feature (aws-kms, gcp-kms, both on by default). |
[seal.awskms]:
| Key | Default | |
|---|---|---|
key_id |
(required) | The KMS key: its ARN (recommended in production), or an alias ARN (resolved at every call, so whoever can retarget the alias picks the key). Every call names it. |
region |
the ARN’s | Needed only when key_id isn’t an ARN. |
endpoint |
the region’s | Rarely needed: a VPC endpoint without private DNS (with it, the region’s usual name already reaches it from inside the VPC), or http:// on loopback only (a test double): the root key is in Encrypt’s request. Loopback is an IP literal or localhost, never decided by DNS. |
Credentials are the AWS SDK’s usual chain, never in this file: the
environment (AWS_PROFILE, AWS_ACCESS_KEY_ID, …), the shared config
with Identity Center sessions, EKS Pod Identity or IRSA, an EC2 instance
profile. Each KMS call ends within 5 seconds, its own retry included.
[seal.gcpkms]:
| Key | Default | |
|---|---|---|
key_name |
(required) | The key’s resource name, projects/<project>/locations/<location>/keyRings/<ring>/cryptoKeys/<key>: never a version (decrypt finds it from the ciphertext). Cloud KMS has no aliases: every call names this key. |
endpoint |
https://cloudkms.googleapis.com |
Rarely needed: a Private Service Connect endpoint, or http:// on loopback only (a test double): the root key is in encrypt’s request. Loopback is an IP literal or localhost, never decided by DNS. |
Credentials are Google’s Application Default Credentials, never in this
file: GKE Workload Identity or a VM’s service account (the metadata
server), GOOGLE_APPLICATION_CREDENTIALS (a key file, or a workload
identity federation config), or gcloud auth application-default login
for development. The server’s identity needs
roles/cloudkms.cryptoKeyEncrypterDecrypter on the key, nothing else.
They’re loaded at the first auto-unseal attempt, not at startup: a
credentials file that’s missing or unreadable (a secret mounted late)
makes the attempt denied, tried again every minute, and the server
starts sealed meanwhile, so the shares still unseal it. Each KMS call ends
within 5 seconds, its own retry (after 200 ms) included.
[metrics]: how metrics leave the server (see
monitoring). Read at startup only.
| Key | Default | |
|---|---|---|
exporter |
(none) | otlp: pushed over OTLP, configured by the standard OTEL_EXPORTER_OTLP_* variables; refuses to start without OTEL_EXPORTER_OTLP_ENDPOINT. prometheus: scraped from listen_addr. none: off. Without it, OTLP when OTEL_EXPORTER_OTLP_ENDPOINT is set, off otherwise. |
listen_addr |
127.0.0.1:9464 |
Prometheus only: GET /metrics, on a listener of its own. Never the main listen_addr or [identity] listen_addr. |
tls |
false on loopback, true elsewhere |
Prometheus only: TLS with the server’s certificate, which needs secured mode. false off loopback serves plaintext there (a startup warning says so): only on a network you trust with what metrics show. |
client_ca |
(none) | Prometheus over TLS only: the CA (PEM) whose client certificates scrapers present. Without it, anyone who reaches the port reads the metrics. |
[[generate_profile]]: how ferritor generate
makes a value (generated secrets). Any
number; reloaded on SIGHUP. Without one named default, a built-in
default: 32 characters of letters, digits and -_., at least one
lowercase, uppercase, digit and one of -_., the first a letter or a digit
(about 193 bits). Those are the characters that need no quoting in a
shell, YAML, a .env file or a URL, and no escaping inside a JSON or TOML
string, so a value pasted somewhere unencoded still works, and a leading - never reads as an
option. For every printable character, replace it (below).
| Key | ||
|---|---|---|
name |
required | Lowercase letters, digits, - and _, 1 to 63 characters; each name once. What --profile names. |
length |
required | The value’s characters, 1 to 100. |
charsets |
required | 1 to 16 sets, each { chars = "…", min = N }: its characters (printable ASCII 33 to 126, no space, each once in its set) and the fewest of them a value holds (default 0). A character in two sets is no likelier for it, and counts toward both minimums. |
first |
(every charset’s) | The characters the first one is drawn from, each also in a charset, each once: a value starting with - reads as an option on a command line, and some systems want a password to start with a letter. Uniform over first, the rest over every charset. |
[[generate_profile]]name = "token"length = 40charsets = [ { chars = "abcdefghijklmnopqrstuvwxyz0123456789" },]
[[generate_profile]]name = "password"length = 20charsets = [ { chars = "abcdefghijklmnopqrstuvwxyz", min = 1 }, { chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", min = 1 }, { chars = "0123456789", min = 1 }, { chars = '!"#$%&*+-=?@^_', min = 2 }, # a literal string: " and \ need no escape]first = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
[[generate_profile]] # the earlier built-in default: all 94 printable charactersname = "default"length = 32charsets = [ { chars = "abcdefghijklmnopqrstuvwxyz", min = 1 }, { chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", min = 1 }, { chars = "0123456789", min = 1 }, { chars = '''!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~''', min = 1 },]Refused at load, so a bad profile stops the server starting (or its
reload), never a generate later: minimums adding up past the length; a
first empty, holding a character twice or one no charset has; fewer
than 80 bits (length × log2 of the distinct characters, the first
character counted by first’s: 20 of 70 is about
122, 16 letters and digits about 95, 8 digits about 27, refused); and
minimums so rare that fewer than one value in a hundred meets them (a test
batch, the same at every load), since a value missing one is drawn again
whole. Sets holding " or \ are easiest as literal strings, '…' or
'''…'''. Each server has its own profiles, and refuses a name it doesn’t
have rather than use another: keep them alike on every server.
[[policy]]: the config rules, for the operators (see policy;
the applications’ grants are stored policies, managed over the API). Each
may have a name, shown as config:<name> (an unnamed one is config:<n>, by
position from 1): each name once, and none an unnamed rule’s number, or the
server refuses to start.
A misspelled key in ferritor.toml refuses to start (unknown top-level keys,
and unknown keys inside [tls], [rate_limit], [identity], [seal], [metrics], [[policy]] and [[generate_profile]]). Environment variables get
no such check: the CLI’s FERRITOR_ADDR, FERRITOR_CA, FERRITOR_CERT,
FERRITOR_KEY, FERRITOR_TOKEN_FILE, FERRITOR_EXCHANGE and
FERRITOR_OIDC_* share the prefix and may be set in the same shell, so a
misspelled FERRITOR_… variable is silently ignored.
A secured setup
Section titled “A secured setup”listen_addr = "0.0.0.0:7070"keys_database_url = "postgres://ferritor@keys-db/ferritor_keys"data_database_url = "postgres://ferritor@data-db/ferritor_data"audit_signing_key = "/etc/ferritor/audit-key.pem"audit_file = "/var/log/ferritor/audit.log"
[tls]cert = "/etc/ferritor/server.pem"key = "/etc/ferritor/server-key.pem"client_ca = "/etc/ferritor/client-ca.pem"crl = "/etc/ferritor/client-ca.crl" # optional
[[policy]]name = "ops-admin"identity = "ops/alice"actions = ["status", "init", "unseal", "seal", "rekey", "rotate", "rewrap", "purge", "destroy_kek", "namespace", "policy", "identity", "schedule"] # init, namespace and policy: a fresh deployment needs themThe applications’ grants then go into stored policies (ferritor policy apply, see policy).
The audit signing key and its public half, for whoever verifies the log:
openssl genpkey -algorithm ed25519 -out audit-key.pem && chmod 600 audit-key.pemopenssl pkey -in audit-key.pem -pubout -out audit.pub.pemThe CLI over TLS: --addr https://… with --ca, --cert and --key (or
FERRITOR_ADDR, FERRITOR_CA, FERRITOR_CERT, FERRITOR_KEY; see
CLI).
Reloading without a restart
Section titled “Reloading without a restart”SIGHUP reloads, while serving:
- the audit log’s file, first: the chain ends in the old file and a new one starts at the path, so logrotate can rename it, then signal (audit log);
- the
[[policy]](each check uses the current one; a call already authorized finishes under the old), and the stored policies; - in secured mode, the server certificate and key (new handshakes present them, so renewing a short-lived certificate needs no restart) and the CRLs (applied to open connections too);
- the keyring, in its own task, so a policy reload (how access is revoked in a hurry) never waits behind it;
- the rotation reminders’ ages (
rotation_max_age_days,kek_max_age_days,root_key_max_age_days,rotation_warn_days), for every due date from then on; - the scheduled tasks’ intervals (
purge_interval_minutes,rewrap_interval_minutes), from the next run this server claims; - the generate profiles (
[[generate_profile]]), for every generate from then on; - the rate limits but
server_max_in_flight(a change to it warns, and waits for a restart). Counters carry over: a reload doesn’t refill anyone’s burst; [identity]butlisten_addrandlifetime_secs: issuers, their keys, mappings and cutoffs, applied to open connections too. Removing the section refuses every certificate it issued; adding it needs a restart.
kill -HUP "$(pidof ferritor-server)"Everything else, the client CA included, needs a restart. Whatever fails to reload (the settings no longer load, an invalid policy, a mismatched key, a certificate not valid now, a switch between dev and secured mode) keeps running as it was and logs loudly. Every attempt is audited, with the fingerprints of what’s now in force.
The audit log’s file is the exception: if its path can’t be opened at a
reopen (the directory gone, the permissions changed), it doesn’t stay on
the old file. Every request that needs an audit entry is refused until the
path can be opened, tried again at every entry, and the server logs AUDIT LOG NOT REOPENED: restore access to the path, and it recovers by itself
(audit log).
The server refuses a certificate that isn’t valid now (expired, or not yet valid), at startup and on reload, and warns if a reloaded one expires sooner than the one it replaces.