Skip to main content
Verify HMAC signatures for Drive API webhooks using current and next secrets to secure session events and CDR forwarding. To ensure secure communication between our Drive API and your backend, we sign all webhook requests using HMAC (Hash-based Message Authentication Code). This guide explains how to verify the HMAC signature on your end to confirm the authenticity and integrity of the received requests. This applies to our different webhooks: Session Events: Documentation CDRs (Charging Detail Records)

HMAC Secret Keys

To enable HMAC, please reach out to us. We will enable it and securely send you two secret keys:
  • CURRENT: The active secret used to sign webhook messages.
  • NEXT: The upcoming secret that will replace CURRENT if a secret key rotation should happen.
Your system should always try to verify the signature with CURRENT and fallback to NEXT. This ensures a smooth transition if we have to rotate secrets, preventing disruptions in webhook processing. More explanation on the key rotation process below.

Verifying the HMAC Signature

Each webhook request includes the X-HMAC-SHA512-Signature header, which contains the base64-encoded HMAC signature of the request’s payload. To verify the signature:
  1. Retrieve the Signature and Payload
    • Extract X-HMAC-SHA512-Signature from the request headers.
    • Extract the raw request body (as a string).
  2. Compute and verify the signature with the CURRENT secret key
    • Compute an HMAC signature of the request body using SHA-512 and the CURRENT secret key.
    • Convert the computed signature to a base64-encoded string.
    • Compare it with the received X-HMAC-SHA512-Signature header. If they match, the request is valid. If not, compute the HMAC signature with the NEXT secret key. If it still doesn’t match, the request should be rejected.

Sample implementation

Javascript

Java

Key Rotation Process

Here is the process for rotating keys:
  1. On our side we sign the payload with NEXT instead of CURRENT. Your system continues working since you verify with both secrets.
  2. We generate a new NEXT secret and securely send it to you. CURRENT takes the value of NEXT and NEXT gets the new value you received from us.