Key rotation drill
Ce contenu n’est pas encore disponible dans votre langue.
In short
Section titled “In short”Rotating the master key means adding a new key that encrypts all new personal data from now on, while keeping the old key so existing data stays readable. The mechanism is described in Encryption keys. This page turns it into a drill: a procedure you rehearse in a test environment, then carry out in production with a checklist, so it goes smoothly when you need it in a hurry.
When to rotate
Section titled “When to rotate”| Situation | Rotate |
|---|---|
| Routine, on the schedule in your security policy (yearly is common) | Planned, in a maintenance window |
| A person who had access to the keys leaves | Soon, planned |
| A key may have been exposed (pasted in a ticket, on a lost laptop, in a leaked backup with its keys) | Immediately, and open a security incident |
Roles in the drill
Section titled “Roles in the drill”Two people, so no single person handles the whole key lifecycle alone:
| Role | Does |
|---|---|
| Operator | Generates the key, updates the secret store, restarts services, verifies |
| Key custodian | Witnesses, stores the new key’s offline backups, signs the record |
Before you start
Section titled “Before you start”- You know where the current value of
SP_SECURITY_MASTER_KEYSlives (your secret manager) and can update it. - You know every place a SpeculaPro process runs: every server, container or pod.
- You have a current database backup (see Backups).
- The key custodian has the materials for offline backups ready (for example, two encrypted USB drives or sealed envelopes).
- You have rehearsed this procedure in a test environment within the last year.
How to rotate
Section titled “How to rotate”-
Write down the current key versions. Look at the current value and note the versions, for example
1. The new key takes the next unused number, here2. Versions can’t be reused, so check your key record, not just the current value. -
Generate the new key, on a trusted machine:
Terminal window speculapro keys generateTake only the base64 part of the
SP_SECURITY_MASTER_KEYS=1:…line. Ignore the version number it prints and the blind index key line: you’re keeping your existing blind index key. -
Build the new value, with the new key first and every old entry kept after it:
Terminal window # beforeSP_SECURITY_MASTER_KEYS=1:OLDKEY…=# afterSP_SECURITY_MASTER_KEYS=2:NEWKEY…=,1:OLDKEY…= -
Back up the new key offline before you deploy it. The custodian makes at least two offline copies, in separate locations, and records the version number and date. A key that reaches production before it is backed up is a key you can lose.
-
Update the secret store with the new value.
-
Restart every SpeculaPro process, one at a time if you need to stay available. Every process must pick up the new value. Until they all have, some will still encrypt with the old key. That’s harmless but delays the rotation.
-
Verify:
- Each process starts without key errors. A malformed value stops the process at start-up with a clear message. See Error messages.
- The health check reports
ok. See Monitoring. - A user who may view personal data can open an existing customer record and see their details. This proves old data is still readable.
-
Record the rotation: date, old and new versions, who did it, who witnessed it, where the backups are, and the reason (routine or incident). Keep this with your security records.
If something goes wrong
Section titled “If something goes wrong”| Symptom | Cause | Fix |
|---|---|---|
Process won’t start: master key vN must be 32 bytes, base64 |
The new key was copied incompletely | Copy it again from the generated output, or generate a new one (and record the version) |
Process won’t start: duplicate master key version N |
The new key reused an existing version number | Use the next unused number |
Existing personal data can’t be read: master key v1 not configured |
An old entry was dropped | Restore the previous entries after the new one and restart |
| Some new records were encrypted with the old key | Not every process was restarted | Restart the stragglers. No harm done; those records stay readable |
Rehearsing the drill
Section titled “Rehearsing the drill”Run the whole procedure once a year in a test environment that mirrors production, ideally the one you use for the restore drill. Time it, note anything unclear, and update your internal runbook.