Karta.Vault.Reencrypt (Karta v1.0.0)

Re-encrypts every secret stored in the database under the active vault key: the DKIM private keys, the TOTP secrets, the webhooks' signing secrets and credentials and extra authentication headers, the keys that sign webhooks in Postal's format, and the secrets, credentials and extra authentication headers of endpoints that receive mail. It is the third step of a key rotation (Karta.Vault): with the old key among the retired keys and a new active key, run/0 rewrites each value; after it, the old key is needed only for message bodies stored before the rotation.

Each table is rewritten in one transaction, its rows locked. A value that no configured key decrypts stops the run with an error, before that table is changed. Running it again changes nothing that matters (values are encrypted afresh). Timestamps are not touched.

In a release: bin/karta eval 'Karta.Release.reencrypt_secrets()'.

Summary

Functions

Re-encrypts all stored secrets; returns how many values of each column were rewritten.

Functions

run()

@spec run() :: %{required(String.t()) => non_neg_integer()}

Re-encrypts all stored secrets; returns how many values of each column were rewritten.