Skip to content

Operator lesson 1: The vault and its keys

See how a forge keeps its keys, rotate the cluster's key, and serve your organization's own keys for encryption and signing.

Time: 25 minutes. Track: operator. Before this: developer lesson 1.

By the end of this lesson you will be able to:

  • say where a forge’s keys live, and what unseals it after every node has stopped;
  • rotate the cluster’s key, and read the keyring’s status;
  • create an organization key, encrypt and decrypt with it, and sign with a post-quantum key.

Where the keys live

Every key the forge holds is sealed under one key, the cluster’s, which lives only in the nodes’ memory. On a production forge, if every node stops, it comes back from recovery shares that people hold; see The vault and recovery keys. A development forge keeps its key in a file instead, so it starts on its own:

$ af-server --dev
...
$ source ~/af-dev/dev/env
$ af vault status
unsealed: its key is kept in a development file
$ af vault rekey status
Error: InvalidState: this cluster keeps its key in a development file: it has no recovery rule to rekey
[1]

Rotate the cluster’s key

The cluster’s key is the root of a keyring. Each term of the keyring is a key of its own; the latest seals everything new, and every earlier term still opens what it sealed. A rotation adds a term. On a forge with one administrator it takes effect at once:

$ af vault rotate --reason "the lesson's rotation"
done: it took effect at once, on your word as an administrator
$ af vault key-status
term 1: installed 2026-11-25T06:33:45.93Z, 5 keys sealed
term 2: installed 2026-11-25T06:33:46.427Z, 0 keys sealed, seals now

Term 1 sealed the forge’s own keys as it started; term 2 seals from now on. Nothing is sealed again under the new term, and a term that has sealed as many keys as one may gives way to the next on its own.

Your organization’s keys

On top of its own keys, the forge is a key management service for your organization. Each key names who may use it; creating one takes effect at once, on your word as an administrator:

$ af kms create app-secrets --use-person dev@localhost
done: it took effect at once, on your word as an administrator
$ printf 'hunter2' | af kms encrypt app-secrets --context env=prod > token.enc
$ af kms decrypt --context env=prod < token.enc
hunter2

The context is bound to the ciphertext: decrypting with another fails.

$ af kms decrypt --context env=test < token.enc
Error: InvalidState: the ciphertext does not open: another key, version or context, or changed
[1]

Sign with a post-quantum key

A signing key can be Ed25519 or ML-DSA-65, the post-quantum signature of FIPS 204:

$ af kms create releases --spec ml-dsa-65 --use-person dev@localhost
done: it took effect at once, on your word as an administrator
$ printf 'v1.0' | af kms sign releases > v1.sig
$ printf 'v1.0' | af kms verify releases --signature "$(cat v1.sig)"
valid
$ printf 'v1.1' | af kms verify releases --signature "$(cat v1.sig)"
Error: the signature does not verify
[1]

Exercises

  1. Rotate the cluster’s key once more, and read the keyring. How many terms are there, and which one seals now?

    $ af vault rotate --reason "a second rotation"
    done: it took effect at once, on your word as an administrator
    $ af vault key-status
    term 1: installed 2026-11-25T06:33:45.93Z, 5 keys sealed
    term 2: installed 2026-11-25T06:33:46.427Z, 2 keys sealed
    term 3: installed 2026-11-25T06:33:46.695Z, 0 keys sealed, seals now

    Term 2 sealed the two keys you made in this lesson; term 3 seals from now on.

  2. Encrypt a second secret under app-secrets with no context, and decrypt it.

    $ printf 'correct horse' | af kms encrypt app-secrets > other.enc
    $ af kms decrypt < other.enc
    correct horse

Check your understanding

After a rotation, can the forge still open what the old term sealed?

Yes. A rotation adds a term; every earlier term stays in the keyring and still opens what it sealed. Nothing is sealed again under the new term.

Why did decrypting with env=test fail?

The context is bound to the ciphertext when it is encrypted, so only the same context opens it. A token for production cannot be read as a test token, even by someone who may use the key.

Next

Operator lesson 2: Repositories, folders and runners.

Type to search…

↑↓ navigate↵ selectEsc close