Rotate the Encryption Key Without Downtime
The backend receives the DFP response in encrypted form and decrypts the payload using a secret key. If you need to replace the key, you can rotate it without affecting DFP operation.
What Key Rotation Is
Key rotation is the replacement of an old encryption key with a new one. It may be required by your internal security policy, after changing the integration setup, or if there is a risk that the old key became available to unauthorized parties.
We perform rotation without downtime: while the key is being replaced, DFP continues to work and your backend continues to decrypt responses. To do this, the backend stores both the old and new keys during rotation and tries them one after another.
How to Rotate the Key
-
Tell us that you want to replace the encryption key.
We will prepare a new
key_newand provide it to you. Keep the oldkey_oldfor now: until the switch, DFP continues to encrypt responses with the old key. -
Add
key_newto the list of keys on the backend.During rotation, your backend stores two keys:
[ key_new, key_old ]
Decryption works as follows: the backend tries to decrypt the payload with the first key. If the key does not work, the backend tries the next one. When it reaches the correct key, the payload decrypts without an error.
-
Ask us to switch encryption to the new key.
From this point on, we encrypt all new DFP responses with
key_new. The backend trieskey_newfirst and decrypts the payload immediately. -
Check that new responses are decrypted.
Make sure DFP requests work normally and the backend receives decrypted results.
-
Wait until old responses are no longer relevant.
Do not delete
key_oldimmediately after the switch. The backend may still receive responses that the browser obtained before the key change but sent later. Use yourtimestampvalidation window as a guide. -
Delete the old
key_old.After this, the backend must decrypt responses only with the new key. The rotation is complete.
What to Do If Decryption Fails
A decryption error may mean that:
-
the backend uses the wrong key;
-
the new key has not yet been added to the backend;
-
we have already switched encryption to the new key, but the backend has not yet been updated;
-
payload,iv, ortagis corrupted in the response; -
the response was modified after it was issued.
If decryption fails:
-
Check that the backend has all keys, both the old and the new one.
-
Make sure the backend tries keys in sequence rather than stopping after the first error.
-
Check which key is currently used for encryption on our side.
-
Save
request_idfrom the DFP response.
If the cause is unclear, contact our support team and provide request_id. We will help investigate it.