Keys and rotation.
The master key that wraps every stored key, and how to rotate each kind of key without downtime.
On this page
The master key
The master key wraps every key the server stores: the TOTP keyring, the OpenID Connect signing key, the audit checkpoint key, and the webhook signing secret. The server never stores the master key itself.
- The first start writes a key-check value and generates one key of each kind. Every later start opens the key-check value first. A master key that doesn’t open it stops the server, so a wrong key never creates a second set of keys.
- Back it up apart from the database. Store it in your password manager or secret store, not beside the database backups. Losing it loses every TOTP secret, so those people enroll again, and every signing key, which the server regenerates.
- Never put it in a variable that a process list or a log can show. Use
TENSILE_AUTH_MASTER_KEY_FILE.
Rotate keys
tensile-auth-server keys status lists each key, when it became active, and how many TOTP secrets each TOTP key still seals. keys rotate KIND adds the next key of one kind:
| Kind | What rotation does |
|---|---|
totp |
The next key seals from 24 hours later. The server reseals each secret on its next use and in an hourly pass |
oidc |
The next key appears in the key set at once and signs from 24 hours later; the old public key stays for 24 hours after that |
checkpoint |
The next key signs from now on; old public keys stay, so old checkpoints keep verifying |
webhook |
The next secret signs from now on, and the old secret also signs for 24 hours |
The server loads keys when it starts. After keys rotate totp or keys rotate oidc, restart every replica within 24 hours, before the next key starts to seal or sign.
After keys rotate webhook, run keys webhook-secret. It prints each live secret as whsec_ and base64, newest first. Give the app both until the old one expires.
To rotate the master key:
-
Generate the new key:
openssl rand -base64 32 > master_key.new. -
Rewrap every stored key under it, in one transaction:
Shelltensile-auth-server keys rewrap --new-master-key-file master_key.new -
Set
master_keyto the new key on every replica, and restart them. A replica that still has the old key refuses to start. -
Back up the new key, then destroy the old one.
To rotate an app key, create a second key with app-key create NAME, deploy it to the app, and revoke the first with app-key revoke ID. app-key list shows every key.