Skip to content

Rotating the master key

Finish each rotation before starting the next, so rows are never under more than two keys.

  1. Set the new key as BROKER_MASTER_KEY and the old one as BROKER_MASTER_KEY_PREVIOUS, and deploy. New writes use the new key; old rows still decrypt.
  2. Wait a few minutes for Workers on the old version to finish, since they still write with the old key.
  3. On the admin page, re-encrypt. Rows move to the new key and keep their versions, and the result says how many remain on an older key. Repeat until none remain.
  4. Archive the old key by id (see Backups and recovery), then remove BROKER_MASTER_KEY_PREVIOUS and deploy.

Re-encryption replaces a row only if its version, key id and IV are unchanged, so a change made at the same time is never overwritten.