Skip to main content
This tutorial starts with a topic, orders, that an encryption Interceptor already encrypts. You change the algorithm, then decide what to do with the records already in orders.

Change the algorithm

Set algorithm in the encryption Interceptor and apply it with the Conduktor CLI or the API. Every Gateway node applies the change without a restart. See choosing an encryption algorithm.
For schema-based encryption, set defaultAlgorithm in the Interceptor and conduktor.algorithm on any field in the schema that sets its own. After the change:
  • New records in orders are encrypted with the new algorithm, under a new data encryption key (DEK).
  • Records already in orders keep the old algorithm. Gateway still decrypts them, because it stores the settings it used with each record: in a record header, or in a topic if you set externalStorage: true before Gateway 3.18.
  • Your consumers read old and new records with no change to the decrypt Interceptor or your clients.

Do you need to act on older records?

Re-encrypt older records

Copy orders through Gateway into a new topic, orders-v2. Gateway decrypts the records as they’re read and encrypts them with the new algorithm as they’re written. Then give the copy the name orders, so your clients don’t change.
  1. Create orders-v2 with the same number of partitions as orders, so records with the same key stay in order.
  2. Check that the encryption Interceptor covers orders-v2.
  3. Run a copy job that reads orders through Gateway with a decrypt Interceptor and writes to orders-v2 through Gateway. For MirrorMaker 2, see the sample configuration.
  4. Stop your producers and consumers, let the copy job catch up, then stop it. Kafka can reset a consumer group’s offsets only while none of its consumers are running.
  5. Delete orders, then create an alias topic named orders that points to orders-v2. Keep this order: Gateway accepts an alias with the same name as an existing topic, and deleting orders would then delete orders-v2.
  6. Restart your producers.
  7. Reset each consumer group to the earliest offset, then start your consumers. Deleting orders deleted the groups’ committed offsets, so consumers using the default auto.offset.reset=latest would skip every copied record. Consumers read again the records they processed before the copy.

Sample MirrorMaker 2 configuration

Run it with connect-mirror-maker.sh mm2.properties --clusters dst.

Check your master key

Gateway wraps each DEK with a key in your Key Management Service (KMS).
  • To rotate that key, see key rotation.
  • If you use the Gateway KMS, keep kmsConfig.gateway.masterKeyId the same. Changing it makes older records unreadable.