Decrypt records in a topic with both encrypted and unencrypted records

Use a condition to decrypt only records that the Encrypt policy encrypted.

If a topic contains both encrypted and unencrypted records, the Decrypt policy fails on unencrypted records because it can’t find a key reference in the kong/enc header.

For example, this happens when you enable the Encrypt policy after the topic already contains records. To prevent this, add a condition that runs the policy only on records that carry the kong/enc header. The Encrypt policy adds this header to every record that it encrypts.

Prerequisites

  • A topic that contains both encrypted and unencrypted records.

  • A static key.

Set up the policy

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!