Launch on 01/01/2027Licenses available from 01/01/2027
PreviewThis page documents the release that launches on 01/01/2027. Packages, images and sign-up open then, and details may change before it.
Docs / Certificates & PKI / step-ca recipes

step-ca recipes

Ready

A deployment trusts one root. The server presents certificates issued under it on each listener, and relying parties, operators and metrics scrapers present certificates issued under it to the server. Phones are not issued certificates: each signs its own, and the server reads only its key. The recipes below set up a CA that issues every certificate a deployment needs, to the certificate contract.

3 recipes are offered, according to what the deployment already has:

  1. An existing CA. The CA issues to the certificate contract. The root’s key stays where that CA keeps it.
  2. step-ca with an offline root. step-ca issues every certificate through an intermediate. The root’s key is kept on a machine that is not networked, and is used once a year, to sign the next intermediate, which lives 3 years. A stolen CA host gives the thief the intermediate’s key, and not the root’s.
  3. step-ca keeping its root. step-ca as it sets itself up: a root and an intermediate, each valid for 10 years, both in the CA’s volume, on a networked host. It is the shortest set-up. Whoever copies the volume can issue any identity in the deployment.

Recipe 3 becomes recipe 2 only before the CA issues its first certificate. intermediate.sh install refuses another root only once no root key is left in the CA’s volume, and recipe 3 keeps one there. An install after the first certificate is therefore accepted, and moves every certificate issued until then under a root the deployment no longer trusts. After the first certificate, a move to an offline root is a replacement of the root (Replacing the root).

What each recipe hands out#

FileGoes to
The root’s certificateThe server (YDFI_SERVER_ROOT_CA_CERT_PATH, and its trust bundles, YDFI_SERVER_CLIENT_CA and YDFI_ADMIN_SERVER_OPERATOR_CA), and every relying party, operator and scraper as its trust anchor. Phones pin it.
A backup root’s certificate (optional)The server (YDFI_SERVER_BACKUP_ROOT_CA_CERT_PATH), which gives phones its pin when they enrol. Its key is kept offline, apart from the main root’s.
The server’s 3 certificate pairsThe server’s listeners, 1 pair each: the relying-party listener, the phone listener and the admin listener. The internal metrics listener serves the relying-party listener’s pair. Each certificate file holds the leaf, then the intermediate. Each pair is renewed in place, and its listener reads the new files without a restart.
A relying party’s certificateThat relying party. Its key is made on the relying party’s machine and never travels.
An operator’s and a scraper’s certificateThe ydfi CLI of that operator, and that scraper.

Recipe 1: an existing CA#

The CA issues what the certificate contract sets out. In brief:

  • Every server and client certificate carries exactly one URI name, spiffe://<trust domain>/<role>/<name>, where the role is server, rp, operator or monitoring, and the trust domain is the server’s YDFI_SERVER_TRUST_DOMAIN.
  • The server’s certificate names every host that clients dial, as DNS names or IP addresses, and lists serverAuth. Client certificates list clientAuth alone, name no DNS name or IP address, and carry no common name equal to the server’s host name. The server also accepts a client certificate that lists serverAuth beside clientAuth, as a SPIFFE CA issues them; one of those that names the server’s host passes a client’s server check where the client checks the host alone, as the Python SDK does. Where the common name is the relying party’s ID, as in the shipped template, no relying party’s ID is that host name.
  • Who may obtain which name is the CA’s own control: a relying party’s certificate names the relying party the operator created, never a name taken from the request.
  • Before each certificate expires, the CA issues the next. A relying party’s certificate reaches its SDK at least the server’s maximum connection age before the old one expires: YDFI_SERVER_STREAM_MAX_CONNECTION_AGE, 30 minutes by default, to which up to a tenth is added, so 33 minutes by default.
  • The configurations of HashiCorp Vault, cert-manager and Google CA Service are in Certificate issuers and deployment platforms.

ydfi validate-env reads the server’s certificate files, the root, the backup root and the trust bundles before the server starts. The server checks the rest of the contract when it starts, and refuses to start on a certificate that breaks it. A client certificate is checked at its first handshake (Checking a deployment).

Recipes 2 and 3: step-ca#

The files served here are those of the release this page belongs to.

Before starting

The recipes need:

  • on the CA’s host, Docker Engine with Docker Compose version 2 (the docker compose command);
  • the step CLI on the server’s host, on the operator’s workstation and on each relying party’s machine, and, for recipe 2, on the offline machine, of the version the CA’s image carries (0.30);
  • a host name for the CA, given in YDFI_CA_DNS_NAMES, that the server’s host and the operator’s workstation resolve.

The 9 files keep the 2 directories the list names, step-ca/ and templates/, side by side in 1 directory that holds nothing else. compose.yml mounts that directory, read-only, in the CA’s container, at /pki:

mkdir -p ydfi-pki/step-ca ydfi-pki/templates
cd ydfi-pki
for f in step-ca/compose.yml step-ca/entrypoint.sh step-ca/provisioners.sh \
         step-ca/intermediate.sh step-ca/offline.sh templates/server.tpl \
         templates/rp.tpl templates/operator.tpl templates/monitoring.tpl; do
  curl -fsS -o "$f" "https://ydentifi.io/docs/step-ca-recipes/$f"
done

A downloaded file cannot be run directly, so the scripts are run with sh, as every command on this page runs them.

The CA runs from step-ca/compose.yml. It is given 3 values in a file .env beside compose.yml: the deployment’s trust domain, the CA’s name, and the host names the CA is reached by, separated by commas. Docker Compose reads the file at every command, and refuses each command without the 3 values. YDFI_TRUST_DOMAIN is the server’s YDFI_SERVER_TRUST_DOMAIN, or ydentifi.local where that is not set: under any other value, the server refuses every client certificate the CA issues. Every docker compose command on this page is run in step-ca/.

cd step-ca
cat > .env <<'EOF'
YDFI_TRUST_DOMAIN=example.com
YDFI_CA_NAME=Example
YDFI_CA_DNS_NAMES=ca.example.internal
EOF
docker compose up -d

docker compose ps shows the CA as healthy once it serves with the contract’s provisioners in place. At its first start, its log (docker compose logs stepca) holds the line entrypoint: the contract's provisioners are in place, under spiffe://<trust domain>.

On its first start, the CA makes its root, its intermediate and its password in the volume stepca. Before it serves, it adds the contract’s 4 provisioners, 1 for each role. Each issues through its role’s template in templates/, under the trust domain given. A request cannot name another trust domain. It cannot name a role’s name of more than 1 path segment.

The 4 provisioners are added together, or not at all. They are added only to a CA that holds the provisioner step-ca makes for itself and none of the contract’s: at the first start, or at the next start when the first was cut short. A CA that has held them is never given them again. A provisioner renamed or removed later therefore stays as it was left. A CA left with none of the contract’s provisioners does not start, and is set up again only from an empty volume.

Once the 4 are in, the CA removes the provisioner step-ca makes for itself, which issues without a template. The CA does not start while any provisioner issues without a template. From its first request, the CA therefore issues through the contract’s templates alone.

step-ca keeps in its configuration the template each provisioner was added with. At each start, before it serves, the CA updates each of the contract’s provisioners whose template differs from its role’s in templates/. A change of the templates, as on an update of the recipes, therefore reaches the CA at its next start (When the templates change).

The CA’s own certificate names localhost beside the names given, for the commands that are run in its container.

Only the server’s certificates can be renewed by their holder. A relying party’s, an operator’s or a scraper’s certificate is issued anew before it expires: 2 years for a relying party’s, 90 days for an operator’s or a scraper’s.

The CA is reached only from the server’s host and from the operator’s workstation. Its port is closed to every other host (Closing the CA’s port).

step-ca renews any certificate under its root that no provisioner issued, whatever the provisioners’ settings say. Whoever holds such a certificate and reaches the CA keeps it valid. A certificate that another CA issued under the same root is of that kind: it is replaced through the provisioners once step-ca issues under that root, and ends at its own expiry. No provisioner stops its renewal, so a stolen one is answered by a new root (Replacing the root).

An old intermediate that the offline root signed is renewed in the same way, as a CA certificate signed by the CA’s current intermediate. Each intermediate that offline.sh sign signs has a path length of 0: a client accepts no CA certificate below it. A client that follows RFC 5280, the standard for these certificates, as Java’s does, does not apply that limit to a certificate whose subject and issuer bear the same name. intermediate.sh request therefore names each intermediate with the time of its request, so that no 2 intermediates share a name. A renewed copy of an old intermediate then signs nothing a client accepts. A renewed copy of the current intermediate names the current intermediate as its issuer, and ends when the current intermediate ends; only the holder of the current intermediate’s key can have it renewed. An intermediate that step-ca issues under, made other than by intermediate.sh request, is held to the same 2 rules: a path length of 0, and a name no other intermediate bears. The old intermediate itself stays valid until its own end (Recipe 2).

step-ca limits a certificate’s lifetime, the time from its start to its end, and not its start date. A request may ask for a certificate that starts later, at any time, and the token does not fix the dates. A certificate that starts after its intermediate’s end is issued, and is refused by every client. The operator signs the requests of relying parties, operators and scrapers, so the operator sets their dates. The server’s requests are signed on the server’s host, so whoever holds the server’s token sets their dates.

Recipe 2: step-ca with an offline root

The root is made on a machine that is not networked, with the step CLI, of the version the CA’s image carries (0.30), and step-ca/offline.sh. The CA makes the intermediate’s key, and only its certificate request travels to the offline machine:

# On the offline machine: the root, its key encrypted with a password that step
# asks for 3 times: to make the key, to read it, and to write it again in the
# PKCS#8 format. It prints the root's fingerprint and its pin.
sh offline.sh root "Example Root CA" root/

# On the CA's host: the intermediate's key, and its request, named with the time of
# the request. It prints the key's fingerprint.
docker compose exec -T stepca sh /pki/step-ca/intermediate.sh request > intermediate.csr

# On the offline machine: the intermediate, valid for 3 years, with the root after
# it, once the request's key has the fingerprint the CA printed, typed from the CA
# host's screen.
sh offline.sh sign root/ intermediate.csr intermediate.pem <key fingerprint>

# On the CA's host: the root and the intermediate replace the CA's own, and the CA's
# root key is deleted.
docker compose exec -T stepca sh /pki/step-ca/intermediate.sh install <root fingerprint> < intermediate.pem

3 values are printed, and each is used once:

  • The root’s fingerprint: the SHA-256 hash of the root’s certificate, on the line offline.sh: the root's fingerprint is …. It is the <root fingerprint> that install takes.
  • The root’s pin: the SHA-256 hash of the root’s public key, in base64url, on the line offline.sh: the root's pin is …. Phones hold it, and the server logs it (Checking a deployment).
  • The request’s key fingerprint, on the line intermediate.sh: the request's key fingerprint is …; offline.sh sign takes it. It is written to the CA host’s screen, not to intermediate.csr. It is the <key fingerprint> that sign takes.

sign ends with the line offline.sh: intermediate.pem holds the intermediate, then the root; …. install ends with intermediate.sh: installed; the root's fingerprint is …, and no root key is left with the CA. The root’s certificate that is handed out is root/root_ca.crt, on the offline machine; step certificate fingerprint root/root_ca.crt prints its fingerprint again.

sign refuses a file that holds anything but 1 PEM block, a certificate request. It refuses a request whose key does not have the fingerprint given. It writes the intermediate only when the intermediate is over that key. A request that is swapped, or added to, on its way is therefore not signed. This holds only while the fingerprint does not travel with the request: whoever swaps the request on its medium can swap a fingerprint written beside it, and the root then signs an intermediate over the swapper’s key. The key’s fingerprint is therefore read on the CA host’s screen and typed on the offline machine.

install refuses a root that does not have the fingerprint given. It refuses an intermediate that the root did not sign, and one that is not over the key of the last request. At the first install, only the root’s fingerprint tells the offline root from another root that signed the CA’s request. The root’s fingerprint is therefore read on the offline machine’s screen and typed on the CA’s host. The root whose certificate goes to the server, the relying parties, the operators and the scrapers, and whose pin phones hold, is the one with that fingerprint.

Once the offline root is installed, install refuses any other root unless replace-root follows the fingerprint. A new root is a replacement of the deployment’s root (Replacing the root).

The last 3 steps are repeated every year. An intermediate lives 3 years: longer than the year until its replacement and the longest certificate issued under it, a relying party’s of 2 years, together. A client checks the dates of each certificate in the chain, so a certificate that outlived its intermediate would fail when the intermediate expires. A certificate issued under the old intermediate stays valid until its own end, since its file carries the intermediate it was issued under.

A root that offline.sh root makes lives 10 years. sign refuses an intermediate that would outlive the root, as an intermediate of 3 years does in the root’s last 3 years. The root is therefore replaced before its 8th year begins (Replacing the root).

Replacing the intermediate withdraws nothing: the old intermediate stays valid under the root until it expires, so whoever copied its key from the CA’s host can still issue under it. After a compromise of the CA’s host, a new CA is set up from an empty volume on a clean host, under a new offline root, with the commands of this recipe, and the deployment’s root is replaced (Replacing the root). The CA’s password and its provisioners’ keys were on the compromised host, and an install with replace-root keeps both, so the old volume is not used again. Every phone enrols again: an enrolled phone keeps the pin of every root it was given, so it goes on trusting what the stolen key signs under the old root, and a move to the backup root does not end that.

The backup root is made the same way, with its own key, in its own directory, and only its certificate goes to the server:

sh offline.sh root "Example Backup Root CA" backup/

Its key, backup/root_ca_key, is kept apart from the main root’s. The server is given its certificate, backup/root_ca.crt, in YDFI_SERVER_BACKUP_ROOT_CA_CERT_PATH, and reads it when it starts. Phones learn its pin when they enrol; a phone that enrolled before the setting was given holds the main root’s pin alone. Phones pin whatever root the server names, so a certificate swapped on its way from the offline machine would be trusted by every phone that enrols after. The pin offline.sh root printed for it is therefore compared, before any phone enrols, with the one the server logs when it starts: on the line that begins backup root pin resolved, in the field spki_pin. offline.sh pin <certificate> prints the pin of a root made before, or elsewhere, such as another CA’s backup root. The rules a backup root is held to are in The certificate contract.

The install comes before any certificate is issued: a certificate issued under the CA’s own root is not trusted once that root is replaced.

Recipe 3: step-ca keeping its root

Nothing more is set up. The root’s certificate is read from the CA, and its fingerprint and pin are printed:

docker compose exec -T stepca cat /home/step/certs/root_ca.crt > root_ca.crt
step certificate fingerprint root_ca.crt
sh offline.sh pin root_ca.crt

The volume holds the root’s key, encrypted with the password beside it. Whoever holds the volume can issue any identity in the deployment, so the volume is backed up, and kept, as the root’s key itself (Backing up and setting up the CA again). A backup root is made offline, as in recipe 2.

The server’s certificates

Each listener is given a certificate pair of its own: the relying-party listener, the phone listener and the admin listener. The internal metrics listener, when it is turned on, serves the relying-party listener’s pair. Clients check 2 things of a server’s certificate: the server’s role in its SPIFFE ID, spiffe://<trust domain>/server/<name>, and the host name they dial. The 3 pairs are therefore told apart by their host names alone, and the admin listener is given a host name of its own. The phone listener’s certificate names the host of YDFI_SERVER_DEPLOYMENT_URL, and its key is ECDSA (The certificate contract).

A token from the CA lets the server’s host make each key and fetch its certificate. The names the token lists are the only ones the certificate carries. main is the server’s instance name, the last part of its SPIFFE ID. --san names the host that the listener’s clients dial. ca.example.internal is the CA’s host name, from YDFI_CA_DNS_NAMES. The token is printed on the CA’s host and carried to the server’s host, where it is given as TOKEN. For the relying-party listener:

# On the CA's host:
docker compose exec -T stepca step ca token main --provisioner ydfi-server \
  --san ydentifi.example.com --password-file /home/step/secrets/password \
  --ca-url https://localhost:9000 --root /home/step/certs/root_ca.crt

# On the server's host, with the token, the root's certificate at
# /etc/ydentifi/ca/ca.crt, and the listener's folder made:
TOKEN='<the token printed on the CA's host>'
cd /etc/ydentifi
step ca certificate main servers/ydfi-server/cert.pem servers/ydfi-server/key.pem \
  --token "$TOKEN" --ca-url https://ca.example.internal:9000 --root ca/ca.crt
step ca renew --daemon servers/ydfi-server/cert.pem servers/ydfi-server/key.pem \
  --ca-url https://ca.example.internal:9000 --root ca/ca.crt

The same 3 commands are run for the phone listener, with the host of YDFI_SERVER_DEPLOYMENT_URL in --san and the files servers/phone/cert.pem and servers/phone/key.pem, and for the admin listener, with its own host name and the files servers/admin-server/cert.pem and servers/admin-server/key.pem.

Each certificate lives 24 hours, unless a longer lifetime is asked for with --not-after, up to 720h (30 days). step ca renew --daemon renews it when 2/3 of its lifetime has passed: after 16 hours, for a certificate of 24 hours. Each daemon runs until it is stopped, so each is run under the host’s service manager, which starts it again with the host. A certificate that has expired is not renewed: a new token is minted, and step ca certificate is run again.

The server reads the files where they are written: /etc/ydentifi is its folder by default, and each file above is at its place in it (Configuration, The server’s folder). Beside the 3 required settings, the trust domain is set, and the backup root where there is one:

YDFI_SERVER_TRUST_DOMAIN=example.com
YDFI_SERVER_BACKUP_ROOT_CA_CERT_PATH=/etc/ydentifi/ca/backup.crt
  • YDFI_SERVER_TRUST_DOMAIN is the CA’s YDFI_TRUST_DOMAIN. Left unset, it is ydentifi.local, and the server refuses every client certificate issued under another trust domain.
  • ca/ca.crt holds the root’s certificate, and nothing else. The server serves it after each listener’s chain, and phones pin it. The relying-party and admin listeners’ trust bundles are that root too, unless YDFI_SERVER_CLIENT_CA or YDFI_ADMIN_SERVER_OPERATOR_CA names another file; the internal metrics listener uses the admin listener’s.
  • YDFI_SERVER_BACKUP_ROOT_CA_CERT_PATH is optional, and has no default (Recipe 2, the backup root).
  • The root, the trust bundles and the backup root are read once, when the server starts. Each listener reads its certificate and key again within 10 seconds of a change, without a restart.
  • The folder holds the server’s files only. The root’s key, and the operators’, scrapers’ and relying parties’ certificates and keys, are kept elsewhere: the server refuses to start while the folder holds ca/ca.key.
  • A server in a container is given the folder, mounted at /etc/ydentifi, not each file alone, so that it sees each renewed file.

ydfi validate-env reads these files before the server starts (Checking a deployment).

A relying party’s, operator’s or scraper’s certificate

The operator creates the relying party first: ydfi admin create-rp --rp-id <rp-id> --name "<name>" --max-users <seats> --reason "<reason>" (Manage RPs & users). The relying party makes its key, which never leaves its machine, and a certificate request that names its ID as the common name and nothing else, and hands the request to the operator. The operator mints a token for that ID; the token names the ID alone. step-ca refuses a request whose common name is another ID, and a request that names any other name. The operator signs the request with the token, from the operator’s workstation. The relying party is handed the certificate, and never reaches the CA:

# On the relying party's machine: the key, written without a password, as the
# SDKs read it, and the request.
step certificate create <rp-id> rp.csr rp.key --csr --no-password --insecure

# On the CA's host: ydfi-rp, ydfi-operator or ydfi-monitoring.
docker compose exec -T stepca step ca token <rp-id> --provisioner ydfi-rp \
  --password-file /home/step/secrets/password \
  --ca-url https://localhost:9000 --root /home/step/certs/root_ca.crt

# On the operator's workstation, with the request and the token:
TOKEN='<the token printed on the CA's host>'
step ca sign rp.csr rp.crt --token "$TOKEN" \
  --ca-url https://ca.example.internal:9000 --root root_ca.crt

<rp-id> is the relying party’s ID, as given to create-rp: letters, digits, ., - and _. The relying party is given rp.crt, which holds its certificate and then the intermediate, and the root’s certificate as its trust anchor. A token is used once, within 5 minutes.

An operator’s certificate is issued the same way, under ydfi-operator, from a request whose common name is the operator’s ID: 1 path segment of letters, digits, ., - and _, chosen by the deployer. Operators are not registered: the admin listener admits every certificate under the root whose SPIFFE ID is on the path /operator/ of the trust domain. The first operator’s certificate is issued before any relying party is created, since every ydfi admin command presents it. The ydfi CLI reads it from ~/.config/ydfi-admin/config.yaml, or from the file that --config names:

server_url: admin.example.com:50060
cert_path: ~/.config/ydfi-admin/operator.crt
key_path: ~/.config/ydfi-admin/operator.key
ca_path: ~/.config/ydfi-admin/root_ca.crt

server_url is the admin listener’s host name and port (YDFI_ADMIN_SERVER_PORT, 50060 by default). The admin listener listens on 127.0.0.1 unless YDFI_ADMIN_SERVER_BIND_ADDR names another address. ydfi admin health answers once the certificate is accepted.

A scraper’s certificate is issued the same way, under ydfi-monitoring, from a request whose common name is the scraper’s instance name. The scraper presents it to the internal metrics listener, at the path /metrics/internal on YDFI_SERVER_INTERNAL_METRICS_PORT, with the root’s certificate as its trust anchor.

When the templates change

At each start, before it serves, the CA updates each of the contract’s provisioners whose template differs from its role’s in templates/, keeping its trust domain, lifetimes and renewal, and logs their names. Until then it issues through the templates it holds. An update of the recipes replaces the 9 files at their paths, and keeps .env. The CA’s container is then made again, so that it reads compose.yml again, which names the CA’s image, and runs the entrypoint; the volume is kept:

docker compose up -d --force-recreate stepca

A provisioner named as the contract’s that is of no role of it, ydfi- followed by anything but a role, stops the CA, which names it with the command that removes it, run with the CA stopped:

docker compose stop stepca &&
  docker compose run --rm --entrypoint sh stepca -c \
    "step ca provisioner remove '<name>' --ca-config /home/step/config/ca.json" &&
  docker compose up -d stepca

A rename takes only a provisioner that issues through its role’s template, so after an update of the recipes the CA is started again before its server’s provisioner is renamed.

When the server’s key is stolen

Revoking the stolen certificate’s serial does not end it: its holder renews it first, with a new serial each time. step-ca finds a certificate’s provisioner by its name, so the server’s provisioner is given a new name, and the CA started again: no certificate the old name issued, the stolen copy’s included, is renewed after that. The command prints the new name, ydfi-server-<YYYYMMDDHHMMSS>, the time of the rename in UTC, under which the server’s host fetches its next certificate, as above, with --provisioner; a later rename names the provisioner by it:

docker compose exec -T stepca sh -c '. /pki/step-ca/provisioners.sh && ydfi_rename_provisioner \
  /home/step/config/ca.json /home/step/secrets/password /pki/templates server ydfi-server' &&
  docker compose restart stepca

The new provisioner is added before the old one is removed. A rename that fails leaves the old one as it was, or, when only the removal failed, says so and gives the command that finishes it; the CA is started again once the rename has succeeded. A name retired is never given again, since a provisioner of that name would renew what the old one issued: each new name carries the time of its rename.

The names retired are kept in the CA’s volume alone: a CA restored from a backup taken before the rename holds the old name again, and a CA set up again from an empty volume holds ydfi-server, and under the same root either renews a stolen server certificate that has not expired. For the 30 days after the rename, the longest a server certificate lives, the server’s provisioner of a CA set up again is renamed, as above, before intermediate.sh install; that of a restored CA is renamed before the CA starts, with the CA stopped, naming the provisioner the backup holds. A rename takes only a provisioner that issues through its role’s template, and a backup taken before an update of the recipes holds the templates of before, so they are updated first:

docker compose stop stepca &&
  docker compose run --rm --entrypoint sh stepca -c '. /pki/step-ca/provisioners.sh &&
    ydfi_update_templates /home/step/config/ca.json /pki/templates &&
    ydfi_rename_provisioner /home/step/config/ca.json /home/step/secrets/password /pki/templates server <name>' &&
  docker compose up -d stepca

A server certificate that step-ca did not issue, as one that another CA issued under the same root, has no provisioner to rename, and step-ca renews it to whoever holds it and reaches the CA; a stolen one is answered by a new root.

On the server’s host, each renewal daemon is stopped. Each listener’s pair is fetched again under the new name, with a new token for each, and step ca certificate … --force writes the new key and certificate over the old files. The daemons are then started again. Each listener serves its new pair within 10 seconds. A stolen certificate that is no longer renewed expires at the end of its lifetime: 24 hours by default, at most 30 days.

Closing the CA’s port

The CA listens on TCP port 9000, which Docker publishes on every interface of the host. A packet to a port that Docker publishes passes Docker’s own firewall rules before the host’s, so a rule in the host’s usual firewall does not close it. On a Linux host, the rules go in the DOCKER-USER chain. Each -I puts its rule first, so the 2 rules written last, which hand the admitted hosts’ packets back to Docker’s rules, come before the rule that drops the rest:

iptables -I DOCKER-USER -p tcp -m conntrack --ctorigdstport 9000 -j DROP
iptables -I DOCKER-USER -p tcp -m conntrack --ctorigdstport 9000 -s <address of the server's host> -j RETURN
iptables -I DOCKER-USER -p tcp -m conntrack --ctorigdstport 9000 -s <address of the operator's workstation> -j RETURN

The rules are kept across restarts by the host’s own means of saving iptables rules. The commands run in the CA’s container reach it at localhost, and are not affected. From a host that is not admitted, curl -sk https://ca.example.internal:9000/health gets no answer; from an admitted host, it returns {"status":"ok"}.

Backing up and setting up the CA again

The CA’s state is its volume, stepca. Docker names the volume after the directory in which docker compose runs: step-ca_stepca for the directory step-ca; docker volume ls lists it. Under recipe 2 the volume holds the intermediate’s key, the provisioners’ keys, and the CA’s password, which encrypts the keys; its backup is kept as the intermediate’s key itself. Under recipe 3 it also holds the root’s key, and its backup is kept as the root’s key itself. The offline root’s key and the backup root’s key, with their passwords, are each kept on a second offline medium: a root whose key is lost signs no further intermediate.

# A backup, with the CA stopped:
docker compose stop stepca
docker run --rm -v step-ca_stepca:/home/step:ro -v "$PWD":/backup alpine \
  tar -C /home/step -czf /backup/stepca.tgz .
docker compose start stepca

# A restore, into the stopped CA's volume:
docker compose stop stepca
docker run --rm -v step-ca_stepca:/home/step -v "$PWD":/backup alpine \
  tar -C /home/step -xzf /backup/stepca.tgz

A restored CA holds the provisioner names it held when the backup was taken. Within 30 days of a rename of the server’s provisioner, it is renamed again before it starts (When the server’s key is stolen); otherwise it is started with docker compose up -d stepca.

A CA is set up again from an empty volume:

docker compose down -v
docker compose up -d

Under recipe 2, the recipe’s 3 steps (request, sign, install), with the same offline root, then put it under that root before it issues any certificate. Every certificate issued before stays valid, since its chain ends at the same root. Under recipe 3, a CA set up again has a new root: without a backup of the volume, the deployment’s root is replaced (Replacing the root).

Replacing the root

The root is replaced as Certificates & PKI sets out: with the server stopped, the root and every certificate under it are replaced, and the server is started again. Under recipe 2 the CA moves to the new root with the recipe’s own commands. A new root is made on the offline machine, or the backup root is used. That root signs the CA’s next intermediate, which is installed with replace-root:

# On the offline machine: a new root, in a directory of its own. For a move to the
# backup root, this step is left out, and backup/ is used below in place of root2/.
sh offline.sh root "Example Root CA 2" root2/

# On the CA's host:
docker compose exec -T stepca sh /pki/step-ca/intermediate.sh request > intermediate.csr

# On the offline machine:
sh offline.sh sign root2/ intermediate.csr intermediate.pem <key fingerprint>

# On the CA's host:
docker compose exec -T stepca sh /pki/step-ca/intermediate.sh install <new root's fingerprint> replace-root < intermediate.pem

From the install, the CA issues under the new root alone. The new root’s certificate is given to every host that reaches the CA, for --root. On the server’s host, the renewal daemons are stopped, each listener’s pair is fetched again with a new token and the new root’s certificate, and the daemons are started again with it. The new root’s certificate replaces ca/ca.crt in the server’s folder, and any file that YDFI_SERVER_CLIENT_CA or YDFI_ADMIN_SERVER_OPERATOR_CA names, and the server is started. On a move to the backup root, YDFI_SERVER_BACKUP_ROOT_CA_CERT_PATH is cleared, or names a new backup root: left naming the root now in use, it stops the server from starting. Each relying party, operator and scraper is then issued its certificate again, as above, with the new root’s certificate as its trust anchor.

Under recipe 3, the CA is set up again from an empty volume, which makes a new root (Backing up and setting up the CA again), or is put under an offline root with the commands of recipe 2. After a compromise of the CA’s host, a new CA is set up from an empty volume on a clean host, under a new offline root (Recipe 2).

What the CA and the scripts refuse

Each refusal is a line on the CA’s log or the script’s output. “…” stands for the rest of the line.

  • entrypoint: YDFI_TRUST_DOMAIN must name the deployment's SPIFFE trust domain, …: .env holds no trust domain, or one that is not lowercase letters, digits, ., - and _. The value is corrected, and the CA started again.
  • provisioners: the CA's provisioners issue under <A>, not <B>; …: the CA was set up under trust domain A and started under B. It is started under A, or set up again from an empty volume.
  • entrypoint: the contract's provisioners could not be set up; …: the lines before it name the cause. The CA adds them at its next start.
  • entrypoint: the CA holds no provisioner of the contract, or one that issues without a template (<names>); …: each provisioner named is removed with the CA stopped, as in When the templates change. A CA with none of the contract’s is set up again from an empty volume.
  • provisioners: '<name>' is of no role of the contract; …: as in When the templates change.
  • entrypoint: the contract's provisioners could not be updated to the templates in /pki/templates; …: the lines before it name the cause.
  • intermediate.sh: no key is waiting for its certificate; …: no request was made, or its intermediate is installed already. intermediate.sh request makes one.
  • intermediate.sh: standard input must hold …: the file given is not the one sign wrote.
  • intermediate.sh: the root given has the fingerprint <A>, not <B>: the file holds another root than the one whose fingerprint was typed, or the fingerprint was mistyped.
  • intermediate.sh: the CA's root is <A>; installing under another root replaces the deployment's root, …: the install changes the root. It is done only as Replacing the root describes.
  • intermediate.sh: the root did not sign the intermediate, … the intermediate is not a CA: the file is not what sign wrote from this root.
  • intermediate.sh: the intermediate is not over the key the last request made: a later request was made. The latest request is signed and installed.
  • offline.sh: <dir> already holds a root, or a key of one; …: another directory is named.
  • offline.sh: the root's key was not written encrypted, as with an empty password; no root is made: a password that is not empty is given.
  • offline.sh: <file> is not one certificate request alone; it is not signed: the request was added to on its way. A new request is made.
  • offline.sh: the request's key is <A>, not the <B> the CA printed; it is not signed: the request was swapped, or the fingerprint mistyped. A new request is made, and its fingerprint read from the CA host’s screen.
  • offline.sh: the root ends within <lifetime>, before the intermediate would; …: the root is in its last years. It is replaced (Replacing the root).
  • provisioners: <name> does not issue through the <role> template; it is not renamed, …: the CA is started once, to update its templates, and the rename is run again.
  • provisioners: <new> is added, but <old> could not be removed …; it is removed with: …: the command the line gives is run, with the CA stopped.

The supported certificate issuers and platforms, and the configuration of each issuer, are on Certificate issuers and deployment platforms.

Opens on 01/01/2027

Available at launch

Until then, you can try the whole ceremony on your own phone.