How-To: Encrypt application state
Preview feature
State store encryption is currently in preview.
Application state often needs to get encrypted at rest to provide stronger security in enterprise workloads or regulated environments. Dapr offers automatic client side encryption based on .
In addition to automatic encryption, Dapr supports primary and secondary encryption keys to make it easier for developers and ops teams to enable a key rotation strategy. This feature is supported by all Dapr state stores.
- Enable the state encryption preview feature using a standard Dapr Configuration:
For example, this is the full YAML of a Redis encrypted state store
You now have a Dapr state store that’s configured to fetch the encryption key from a secret named , containing the actual encryption key in a key named mykey
. The actual encryption key must be an AES256 encryption key. Dapr will error and exit if the encryption key is invalid.
Note that the secret store does not have to support keys
When Dapr starts, it will fetch the secrets containing the encryption keys listed in the section. Dapr knows which state item has been encrypted with which key automatically, as it appends the secretKeyRef.name
field to the end of the actual state key.
To rotate a key, simply change the to point to a secret containing your new key, and move the old primary encryption key to the secondaryEncryptionKey
. New data will be encrypted using the new key, and old data that’s retrieved will be decrypted using the secondary key. Any updates to data items encrypted using the old key will be re-encrypted using the new key.