Production deployment
From nothing to a secured server holding its first secret: two databases, a
small PKI, a ferritor.toml, the first init and unseal, a namespace, and an
application reading its secret over mTLS. Each step links to the topic that
explains it. In Kubernetes, the Kubernetes guide
puts the same pieces in a cluster.
What you need
Section titled “What you need”- Two Postgres databases, the keys database and the data database, on separate servers if you can: each alone yields wrapped keys, never usable ones. With several ferritor servers or any failover, both need synchronous replication; read high availability before going live.
- Two CAs: one that signs the server’s certificate (clients trust it), and one that issues client certificates (the server trusts it). They can be intermediates of your existing PKI; the commands below make standalone ones with OpenSSL.
- Operators to hold the unseal shares: by default 5, any 3 of which unseal. The server starts sealed after every restart, so they must be reachable whenever it restarts.
curland cosign, to fetch a release and verify it.
1. The binaries
Section titled “1. The binaries”Each GitHub release has
an archive per architecture, x86_64 and aarch64, of the four static
binaries (ferritor-server, ferritor, ferritor-agent,
ferritor-csi-provider, any Linux), with a cosign signature and the
release’s checksums. Verify it before it’s unpacked: its signature must
name ferritor’s release workflow, and its checksum match.
version=1.3.0dir=ferritor-$version-$(uname -m)-unknown-linux-muslfor f in "$dir.tar.gz" "$dir.tar.gz.sigstore.json" SHA256SUMS; do curl -fsSLO "https://github.com/ferritor/ferritor/releases/download/v$version/$f"donecosign verify-blob "$dir.tar.gz" --bundle "$dir.tar.gz.sigstore.json" \ --certificate-identity https://github.com/ferritor/ferritor/.github/workflows/release-plz.yml@refs/heads/main \ --certificate-oidc-issuer https://token.actions.githubusercontent.com && sha256sum -c SHA256SUMS --ignore-missing && tar -xzf "$dir.tar.gz" && sudo install -m 0755 "$dir/ferritor-server" "$dir/ferritor" /usr/local/bin/Each step runs only if the one before succeeded: a signature or a checksum that doesn’t match stops it before anything is unpacked.
The server needs ferritor-server; operators and scripts need ferritor,
the CLI, which also runs on macOS and Windows Server: its own archives,
verified the same way (CLI). In containers, the
release’s signed images are the same binaries
(Kubernetes). To build from
source instead, see development.
2. Databases
Section titled “2. Databases”One database and one login role per side; the role owns its database, because the server runs that database’s migrations itself at startup:
-- on the keys database's serverCREATE ROLE ferritor_keys LOGIN PASSWORD '…';CREATE DATABASE ferritor_keys OWNER ferritor_keys;
-- on the data database's serverCREATE ROLE ferritor_data LOGIN PASSWORD '…';CREATE DATABASE ferritor_data OWNER ferritor_data;Never give one role access to both databases. Plan the backups now: they must be taken in the right order, and the shares go with the keys database’s generation (see backup and restore).
3. Certificates
Section titled “3. Certificates”The requirements (see TLS and identity):
- The server certificate has a DNS SAN for every name clients connect
to, and the
serverAuthextended key usage. - Each client certificate has exactly one URI SAN,
ferritor://<name>: the<name>is the identity the policy grants actions to (ops/alice,apps/billing; it follows the secret-path rules). It needs theclientAuthextended key usage and must be issued directly by a CA inclient_ca. The subject CN plays no part. - Without a CRL file, a client certificate can’t be revoked, only expire:
keep them short-lived, or set up
[tls] crl(see TLS).
A minimal PKI with OpenSSL (Ed25519 keys; any key type rustls accepts works):
#!/usr/bin/env bashset -euo pipefail
ca() { # ca <file> <CN> openssl genpkey -algorithm ed25519 -out "$1.key" openssl req -x509 -new -key "$1.key" -subj "/CN=$2" -days 3650 -out "$1.pem" \ -addext "basicConstraints=critical,CA:TRUE" \ -addext "keyUsage=critical,keyCertSign,cRLSign"}ca server-ca "ferritor server CA"ca client-ca "ferritor client CA"
# The server: one DNS SAN per name clients use.openssl genpkey -algorithm ed25519 -out server-key.pemopenssl req -new -key server-key.pem -subj "/CN=ferritor.example.internal" -out server.csrcat > server.ext <<XsubjectAltName = DNS:ferritor.example.internalextendedKeyUsage = serverAuthkeyUsage = critical, digitalSignaturebasicConstraints = critical, CA:FALSEsubjectKeyIdentifier = hashauthorityKeyIdentifier = keyid, issuerXopenssl x509 -req -in server.csr -CA server-ca.pem -CAkey server-ca.key -days 90 \ -extfile server.ext -out server.pem
# A client: its identity is the URI SAN. (A `/` in -subj would start a new# attribute, so the file names and CN use `-`.)client() { # client <identity> local f=${1//\//-} openssl genpkey -algorithm ed25519 -out "$f-key.pem" openssl req -new -key "$f-key.pem" -subj "/CN=$f" -out "$f.csr" cat > "$f.ext" <<XsubjectAltName = URI:ferritor://$1extendedKeyUsage = clientAuthkeyUsage = critical, digitalSignaturebasicConstraints = critical, CA:FALSEsubjectKeyIdentifier = hashauthorityKeyIdentifier = keyid, issuerX openssl x509 -req -in "$f.csr" -CA client-ca.pem -CAkey client-ca.key -days 30 \ -extfile "$f.ext" -out "$f.pem"}client ops/alice # an operatorclient apps/billing # an applicationThe key identifiers aren’t needed by ferritor, but strict clients require them: Python 3.13 and later refuses a server certificate without an Authority Key Identifier.
Keep server-ca.key and client-ca.key off the ferritor host. The server
needs server.pem, server-key.pem and client-ca.pem; clients need
server-ca.pem and their own certificate and key.
4. The audit signing key
Section titled “4. The audit signing key”The audit log (its own file, audit_file) is hash-chained and signed with
an Ed25519 key, required in secured mode:
openssl genpkey -algorithm ed25519 -out audit-key.pem && chmod 600 audit-key.pemopenssl pkey -in audit-key.pem -pubout -out audit.pub.pem # for whoever verifies the log5. Configuration
Section titled “5. Configuration”/etc/ferritor/ferritor.toml (start from ferritor.example.toml, which documents
every setting; see configuration). [tls], at least one
[[policy]] and audit_signing_key together make it secured, with
somewhere for the audit log: audit_file (here), a collector
([audit_otlp]), or both. Anything in between refuses to start.
listen_addr = "0.0.0.0:7070"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"
# The operator: every admin action (init, namespace and policy are needed# to start). Applications' access goes into stored policies (step 8).[[policy]]name = "ops-admin"identity = "ops/alice"actions = ["status", "init", "unseal", "seal", "rekey", "rotate", "rewrap", "purge", "destroy_kek", "namespace", "policy", "identity", "schedule"]Keep the database passwords out of the file: pass the URLs as
FERRITOR_KEYS_DATABASE_URL and FERRITOR_DATA_DATABASE_URL from your secret
store. Make the server’s keys (server-key.pem, audit-key.pem) readable by
its user only; startup warns about an audit key others can read. See
policy for granting actions and paths. Keep the config rules
to the operators (and anything that must work while sealed, such as a
monitoring identity’s status); the applications’ grants are managed as
stored policies, over the API, in the next steps.
6. Run it
Section titled “6. Run it”The server reads ferritor.toml from its working directory. Its own logs
go to stderr; the audit log goes to audit_file alone: ship that file
off the host as it’s written (see audit log), or send
it to a collector instead ([audit_otlp]). A systemd unit, as a starting
point:
[Unit]Description=ferritor secret managerAfter=network-online.targetWants=network-online.target
[Service]User=ferritorWorkingDirectory=/etc/ferritor# FERRITOR_KEYS_DATABASE_URL=… and FERRITOR_DATA_DATABASE_URL=…, readable by root onlyEnvironmentFile=/etc/ferritor/database.envExecStart=/usr/local/bin/ferritor-serverExecReload=/bin/kill -HUP $MAINPID# The logs (stderr) to the journal; the audit log to /var/log/ferritor# (audit_file), which systemd creates for the service's user, writable under# ProtectSystem=strict, and only theirs.StandardError=journalLogsDirectory=ferritorLogsDirectoryMode=0700TimeoutStopSec=30Restart=on-failure# Hardening (https://ferritor.dev/concepts/security): the unsealed# server holds the root key and every KEK in memory. It marks itself# undumpable at startup (no core dumps, no same-user ptrace or# /proc/<pid>/mem); these add the rest. ferritor writes nothing but the# audit log, so the system can be read-only outside LogsDirectory.# Its memory, keys included, never goes to swap (cgroup v2).MemorySwapMax=0LimitCORE=0NoNewPrivileges=trueCapabilityBoundingSet=ProtectSystem=strictProtectHome=truePrivateTmp=truePrivateDevices=trueProtectKernelTunables=trueProtectKernelModules=trueProtectControlGroups=trueMemoryDenyWriteExecute=trueLockPersonality=trueRestrictSUIDSGID=trueRestrictNamespaces=trueRestrictAddressFamilies=AF_INET AF_INET6 AF_UNIXSystemCallFilter=@system-service
[Install]WantedBy=multi-user.target(systemd takes comments only on lines of their own, never after a setting.)
These settings were tested as a system service (systemd 262, a non-root
user, every setting as above) with the server serving gRPC and the JSON API
under load, both databases, a SIGHUP reload and a draining stop, whose audit
log then verified; and again with audit_file in LogsDirectory=: systemd
created the directory 0700 for the service’s user, the server its file
0600; a rename then systemctl reload moved the log to a new file, and
so did two rounds of the audit log’s
logrotate configuration (the second compressing the first’s file), every
file verifying as complete. Test them on your own hosts before relying on
them.
systemd-analyze security ferritor rates the unit 2.2, “OK” (8.3 without the
hardening). If a setting conflicts with something your hosts add (a
monitoring library loaded into the process, a different libc), drop that one
rather than the block, and say so in your unit.
Swap. MemorySwapMax=0 keeps the service’s memory out of swap without
turning swap off for the host, on cgroup v2 (every current distribution).
Without cgroup v2, run the host without swap, or with swap encrypted under
a key that doesn’t survive a reboot (dm-crypt with a random key).
Hibernation writes all of memory to disk whatever the cgroup says: don’t
let a ferritor host hibernate. ferritor doesn’t lock its memory (mlock): its
keys live in ordinary heap allocations.
Rotating the audit log file. Rename it, then SIGHUP (systemctl reload ferritor): the server ends the chain in the old file and starts one in a
new file at the path, so each file verifies on its own. The
audit log has a logrotate configuration for it
(delaycompress, never copytruncate). Have a log collector (Vector,
Fluent Bit, …) follow the file and ship it as it’s written too, which you
want anyway.
SIGTERM drains in-flight calls and writes the audit log’s signed
chain_end; SIGHUP (systemctl reload ferritor) reopens the audit log and
reloads the policy, the server certificate, the CRLs and the keyring (see
configuration, operations).
7. Initialize and unseal
Section titled “7. Initialize and unseal”From an operator’s machine, with the operator’s certificate:
export FERRITOR_ADDR=https://ferritor.example.internal:7070export FERRITOR_CA=server-ca.pem FERRITOR_CERT=ops-alice.pem FERRITOR_KEY=ops-alice-key.pem
ferritor status # not initializedferritor init --shares 5 --threshold 3 # prints the 5 shares, onceThen any three operators unseal, each with their own share (read from stdin, a hidden prompt on a terminal; never a command-line argument):
ferritor unseal # once per share, until the thresholdferritor status # unsealedEvery restart starts sealed again and needs this step, unless the servers
unseal themselves (below). A load balancer’s readiness check on
ferritor.v1.SecretsService (gRPC health) or GET /v1/health keeps a sealed
server out of rotation (see operations).
Auto-unseal with AWS KMS (optional)
Section titled “Auto-unseal with AWS KMS (optional)”For servers that must come back without people (autoscaling, Kubernetes), let them unseal themselves through AWS KMS (key management). It puts the KMS key’s access control inside ferritor’s trust boundary (see security), so set it up narrowly:
-
A symmetric key (
SYMMETRIC_DEFAULT,ENCRYPT_DECRYPT) for ferritor alone, in an account separate from the databases’ backups if you can. Refer to it by its key ARN, not an alias. -
A role for the servers, never long-lived access keys: an EC2 instance profile, EKS Pod Identity or IRSA. In the key’s policy, only these, for that role:
{"Effect": "Allow","Principal": {"AWS": "arn:aws:iam::111122223333:role/ferritor-server"},"Action": ["kms:Encrypt", "kms:Decrypt"],"Resource": "*","Condition": {"StringEquals": {"kms:EncryptionContext:ferritor:purpose": "root-key","aws:SourceVpce": "vpce-0123456789abcdef0"}}}plus
kms:DescribeKeyfor the same role. Theaws:SourceVpce(oraws:SourceVpc) condition is optional hardening: with the servers reaching KMS through an interface VPC endpoint, stolen role credentials are useless from anywhere else. Servers in private subnets without internet access need that endpoint anyway. With its private DNS on (the default) the region’s usual KMS name resolves to it inside the VPC, so[seal.awskms] endpointstays unset; without the condition, the public endpoint works as is. No broadkms:*admin role on this key: whoever may change its policy may grant themselvesDecrypt. -
[seal]in every server’s config (the same on each), then a rekey to store the first wrap if the deployment started under Shamir:ferritor unsealwith the shares,ferritor rekey start …(see key management). A new deployment just runsferritor initwith[seal]already set. -
Alarms on CloudTrail:
Decryptfrom anywhere but the VPC endpoint,Decryptmore often than servers start, and anyEncryptoutside a planned init or rekey.
Auto-unseal with Google Cloud KMS (optional)
Section titled “Auto-unseal with Google Cloud KMS (optional)”The same with Google Cloud KMS (provider = "gcpkms"), instead of AWS:
one provider at a time. The same trust applies: whoever can use the key
and read the keys database has the root key.
-
A symmetric key for ferritor alone, in its own key ring, ideally in a project of its own, separate from the databases’ backups. Protection level
hsmkeeps it in an HSM; a destruction delay leaves time to undo a mistake:Terminal window gcloud kms keyrings create ferritor --location asia-southeast1 --project my-projectgcloud kms keys create root-key --keyring ferritor --location asia-southeast1 \--project my-project --purpose encryption --protection-level hsm \--destroy-scheduled-duration 30d[seal.gcpkms] key_nameis its resource name,projects/my-project/locations/asia-southeast1/keyRings/ferritor/cryptoKeys/root-key. -
An identity for the servers, never a key file if you can avoid it: GKE Workload Identity, or the VM’s service account. Grant it
roles/cloudkms.cryptoKeyEncrypterDecrypteron this key only, never on the key ring or the project:Terminal window gcloud kms keys add-iam-policy-binding root-key --keyring ferritor \--location asia-southeast1 --project my-project \--member serviceAccount:ferritor-server@my-project.iam.gserviceaccount.com \--role roles/cloudkms.cryptoKeyEncrypterDecrypterWith GKE Workload Identity, the member can be the server’s Kubernetes service account itself:
principal://iam.googleapis.com/projects/<project-number>/locations/global/workloadIdentityPools/my-project.svc.id.goog/subject/ns/<namespace>/sa/<service-account>. ferritor reads no key metadata, so no other role is needed. IAM can’t require ferritor’s additional authenticated data, so the role is the whole restriction: keep the key for ferritor alone. Optional hardening: a VPC Service Controls perimeter around the project, so stolen credentials can’t use the key from outside it (with a Private Service Connect endpoint, set[seal.gcpkms] endpoint). Keepcloudkms.adminon the key, and the right to impersonate the servers’ service account (roles/iam.serviceAccountTokenCreator), away from everyone else: both lead todecrypt. -
[seal]in every server’s config, thenferritor init, or a rekey (--seal gcpkms) for a deployment that started under Shamir or another provider, as for AWS above. -
Cloud KMS’s Data Access audit logs, which are off by default: without them, a
decryptleaves no trace. Turn onDATA_READandDATA_WRITEforcloudkms.googleapis.com(IAM & Admin, Audit Logs), then alert onDecryptby any principal but the servers’, on aDecryptthrough impersonation (serviceAccountDelegationInfoset), on moreDecrypts than servers start, and on anyEncryptoutside a planned init or rekey. The entries are in Cloud Logging, undercloudaudit.googleapis.com%2Fdata_access, kept 30 days unless routed elsewhere.
8. The first namespace and secret
Section titled “8. The first namespace and secret”Nothing can be stored until a namespace exists: a secret’s path starts with its namespace, and each namespace has its own KEKs (see key management).
ferritor namespace create billing --label team=paymentsThen the application’s access, as a stored policy. Keep the set in a file
under version control and apply it whole (--dry-run shows the change
first; see policy):
[[policy]]name = "apps/billing"identity = "apps/billing"actions = ["read", "write", "list"]paths = ["billing"]description = "the billing app: its own secrets"ferritor policy apply -f policies.toml --dry-runferritor policy apply -f policies.tomlferritor policy check --identity apps/billing --action read --path billing/dbThe application, with its own certificate:
export FERRITOR_CERT=apps-billing.pem FERRITOR_KEY=apps-billing-key.pemprintf 's3cret' | ferritor put billing/dbferritor get billing/db
# or the JSON API, on the same port (value in base64):curl --cacert server-ca.pem --cert apps-billing.pem --key apps-billing-key.pem \ https://ferritor.example.internal:7070/v1/secrets/billing/dbIts policy grants billing only: anything else, namespace management
included, is PERMISSION_DENIED. See secrets for versions,
check-and-set, delete and restore.
An application that reads its secrets from files rather than the API gets
them from the agent: ferritor-agent next to it, with a
certificate of its own (an identity granted read on exactly what it
renders), writing one file per secret into a memory-backed directory and
keeping them current; in Kubernetes, the CSI provider does it once
per node for every pod, each with its own identity.
Workloads without certificates (optional)
Section titled “Workloads without certificates (optional)”Workloads that already get a token from their platform (Kubernetes service accounts, a CI system’s OIDC tokens) can exchange it for a certificate instead of being issued one (workload identity):
ferritor identity initonce (an operator withidentity, unsealed).- An
[identity]section with the issuer and its mappings (the configuration); for Kubernetes, its JWKS fromkubectl get --raw /openid/v1/jwksintojwks_file, or its issuer’sjwks_urlif it’s reachable. Openlisten_addr(7071 in the example) to the workloads, restart, and send every server the same section. - Stored policies for the identities the mappings produce
(
k8s-prod/billing/api). - The workload: the agent with
token_fileandexchange, a projected token with audienceferritor(agent); a CI job withferritor --token-file … --exchange …orferritor login.
9. Before going live
Section titled “9. Before going live”- Audit log: check it can be verified, e.g. after a restart:
ferritor audit verify --public-key audit.pub.pem < audit.log(exit 0: every entry signed). Only a chain ending in a signedchain_endis proven. - Purge on a timer:
ferritor purgeremoves deleted versions pastpurge_deleted_after_days; it’s safe to rerun or interrupt. - Certificates: renew the server certificate before it expires (the
ferritor.server_certificate.expirygauge), thensystemctl reload ferritor; keep client certificates short-lived or publish a CRL. - Metrics: set
OTEL_EXPORTER_OTLP_ENDPOINT, or[metrics] exporter = "prometheus"for a scrape (configuration), and alert on what operations lists (ferritor.sealed,ferritor.kek.vanished,ferritor.audit.queue.depth, the expiry gauges). - Rate limits: on by default (calls in flight, per identity and per
server). An application that runs many calls at once (a batch job, a
fleet behind one identity) needs an entry of its own under
[[rate_limit.identity]]: see operations for sizing, and alert onferritor.rate_limit.refused. - Backups and failover: take a first pair of backups, in the right order, and test a restore (backup and restore); with replication, read high availability, including what to do after a failover.
- Key rotation:
ferritor rotate --namespace billing, thenferritor rewraponce every server has refreshed (see key management). With workload identity,ferritor identity rotatebefore the issuing CA’s expiry (ferritor identity status), and know the emergency steps (revoking). - Policies from a source of truth: apply
policies.tomlfrom CI with--prune, so the stored set is always what’s reviewed; after restoring the keys database, re-apply it before routing traffic (backup and restore). Alert onferritor.policy.revisiondiffering between servers, and onpolicy_reloadaudit entries with resultintegrityorrollback.