{"templateId":"markdown","versions":[{"version":"v1.44","label":"v1.44 STS","link":"/pt-br/products/custody/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","default":true,"active":true,"folderId":"714bb270"},{"version":"v1.43","label":"v1.43 LTS","link":"/pt-br/products/custody/v1.43/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","default":false,"active":false,"folderId":"714bb270"},{"version":"v1.42","label":"v1.42 STS","link":"/pt-br/products/custody/v1.42/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","default":false,"active":false,"folderId":"714bb270"},{"version":"v1.34","label":"v1.34 LTS","link":"/pt-br/products/custody/v1.34/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","default":false,"active":false,"folderId":"714bb270"},{"version":"v1.26","label":"v1.26 LTS","link":"/pt-br/products/custody/v1.26/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","default":false,"active":false,"folderId":"714bb270"},{"version":"v1.19","label":"v1.19 LTS","link":"/pt-br/products/custody/v1.19/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","default":false,"active":false,"folderId":"714bb270"},{"version":"v1.15","label":"v1.15 LTS","link":"/pt-br/products/custody/v1.15/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","default":false,"active":false,"folderId":"714bb270"}],"sharedDataIds":{"sidebar":"sidebar-@l10n/pt-BR/products/custody/@v1.15/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition","tabs","tab"]},"type":"markdown"},"seo":{"title":"Verify webhook signatures","description":"User guides, API reference, and support resources.","siteUrl":"https://docs.ripple.com","lang":"en-US"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"verify-webhook-signatures","__idx":0},"children":["Verify webhook signatures"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ripple Custody (Vault)"," signs every webhook delivery, so your endpoint can confirm that a request came from your ","Ripple Custody (Vault)"," instance and that nobody changed it in transit. Signing uses Ed25519 keys and follows the asymmetric (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1a"]},") scheme of the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.standardwebhooks.com/"},"children":["Standard Webhooks"]}," specification. You can verify each delivery with a public key that ","Ripple Custody (Vault)"," publishes, so no shared secret is exchanged."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Signing is on for all webhook channels from version 1.44. Verifying the signature is optional, but recommended. Signing only adds HTTP headers to each delivery: the request body is unchanged, and an endpoint that ignores the headers keeps working."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"how-signing-works","__idx":1},"children":["How signing works"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ripple Custody (Vault)"," holds the private signing keys. They're stored encrypted and are never exposed, including to Ripple support staff."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ripple Custody (Vault)"," publishes the matching public keys at an unauthenticated JWKS (JSON Web Key Set) endpoint."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The signing key belongs to the environment, not to a channel: every webhook channel in an environment is signed with the same key. Each environment, for example your test and production environments, has its own keys, so get the keys from each environment that sends you webhooks."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The signature proves that a delivery came from your ","Ripple Custody (Vault)"," instance, not which domain or channel it was sent to. All domains on the instance share the signing key, so also check the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["domainId"]}," in the body. See step 7 of ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#verify-a-delivery"},"children":["Verify a delivery"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Every delivery attempt, including retries and test deliveries, is signed. ","Ripple Custody (Vault)"," never sends an unsigned delivery."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ripple Custody (Vault)"," rotates the signing key automatically once a year, with a 30-day overlap during which deliveries carry two signatures."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"signature-headers","__idx":2},"children":["Signature headers"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each delivery carries three headers:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"http","header":{"controls":{"copy":{}}},"source":"POST /your/webhook/endpoint HTTP/1.1\nContent-Type: application/json\nwebhook-id: 7f1f6a5e-3c1d-4b8e-9d7a-2f0c9b1e4a6d\nwebhook-timestamp: 1793280000\nwebhook-signature: v1a,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4CjtXGXzpbrsYzBLXQ7STBvn7oRf2FKBWqL+mZbN0uBg==\n\n{\"domainId\":\"25aaec0d-e8dc-44b6-8070-9231f1ddadf0\",\"payload\":{...},\"id\":\"...\",\"sequenceNumber\":42,\"savedAt\":\"...\"}\n","lang":"http"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Header"},"children":["Header"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unique ID of this delivery: one event on one channel. The ID stays the same across retries and when ","Ripple Custody (Vault)"," re-sends a pending event, so you can use it to discard duplicates. It's different from the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," field in the body, which all channels of a domain share."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-timestamp"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Time of this delivery attempt, in Unix seconds. Each retry gets a new timestamp and a new signature."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-signature"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One or more signatures, separated by spaces. Each has the form ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1a,<signature>"]},", where the signature is a standard Base64-encoded Ed25519 signature. During a key rotation, the header carries two signatures."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The signed content is the UTF-8 string ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{webhook-id}.{webhook-timestamp}."]}," followed by the exact bytes of the request body."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"get-the-public-keys","__idx":3},"children":["Get the public keys"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Retrieve the public keys from the JWKS endpoint. The endpoint doesn't require authentication."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sh","header":{"controls":{"copy":{}}},"source":"curl -X GET \"${CUSTODY_API_URL}/v1/webhook-signing-keys\"\n","lang":"sh"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"keys\": [\n    {\n      \"kty\": \"OKP\",\n      \"crv\": \"Ed25519\",\n      \"kid\": \"6906b6d6-d2ad-480b-9be3-28a191726584\",\n      \"x\": \"<base64url public key>\",\n      \"whpk\": \"whpk_<base64 public key>\",\n      \"use\": \"sig\",\n      \"status\": \"active\",\n      \"exp\": 1823558400\n    },\n    {\n      \"kty\": \"OKP\",\n      \"crv\": \"Ed25519\",\n      \"kid\": \"331e90d1-c6d7-4b55-8823-00f553ef3be5\",\n      \"x\": \"<base64url public key>\",\n      \"whpk\": \"whpk_<base64 public key>\",\n      \"use\": \"sig\",\n      \"status\": \"next\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kty"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["crv"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Key type and curve. Always ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OKP"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Ed25519"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kid"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Key ID, a UUID. The signature header doesn't include it, so try every key in the set."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["x"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The public key, Base64url-encoded without padding."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["whpk"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The same public key in the Standard Webhooks format: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["whpk_"]}," followed by the key, standard Base64-encoded with padding. Use it with Standard Webhooks libraries and tools that take a key in that form."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["use"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Always ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sig"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One of the following:",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["active"]},": the key that signs deliveries.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]},": the key that will replace it at the next rotation.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["retiring"]},": the previous key, during the 30-day overlap after a rotation. It still signs deliveries, together with the active key."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exp"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Time at which scheduled rotation stops publishing the key, in Unix seconds. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["active"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["retiring"]}," keys carry it; the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key doesn't. For the active key, it's when the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key is scheduled to replace it. For the retiring key, it's the scheduled end of the 30-day overlap. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exp"]}," is a schedule, not a deadline: rotation can be delayed, and the active key keeps signing after its ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exp"]}," until it rotates. Don't drop a key only because its ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exp"]}," has passed."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The response carries ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Cache-Control: public, max-age=86400"]},", so you can cache the key set for up to 24 hours. If the endpoint returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["503 Service Unavailable"]},", ","Ripple Custody (Vault)"," couldn't check the keys against its key store: keep the keys you hold and retry later."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can store the public keys in either of two ways: cache them and refresh them every day, or store them until the planned rotation. For details, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#scheduled-rotation"},"children":["Scheduled rotation"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"verify-a-delivery","__idx":4},"children":["Verify a delivery"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To verify a delivery, we recommend the following procedure, before you process the event:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Read the raw body."]}," Verify the exact bytes you received, before any JSON parsing. A parsed and re-serialized body doesn't match the signature."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Check the timestamp."]}," Reject the request if ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-timestamp"]}," is more than 5 minutes from your current time. This stops an attacker from replaying a captured delivery."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Discard duplicates."]}," If you've already processed this ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-id"]}," in the last 24 hours, return ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2xx"]}," and skip it. Retries and re-sends reuse the same ID."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Build the signed content:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-id"]}," + ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["."]}," + ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-timestamp"]}," + ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["."]}," + raw body."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Verify the signature."]}," For each ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1a"]}," entry in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhook-signature"]},", and each key in the key set, call a standard Ed25519 verify function with the public key, the signed content, and the decoded signature. One match is enough."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["If nothing matches, refresh the keys once."]}," If your cached key set is more than 5 minutes old, fetch it again and repeat step 5. If there's still no match, reject the request."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Check the domain."]}," Parse the body and check that its ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["domainId"]}," is the domain where you created the webhook channel. If it isn't, reject the request. Always make this check: one signing key signs the deliveries of every domain on your ","Ripple Custody (Vault)"," instance, and the signature doesn't identify the domain that a delivery was sent to. Without the check, a user who can manage webhook channels in another domain on the same instance could forward genuinely signed events from that domain to your endpoint."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Acknowledge."]}," Return ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2xx"]}," only after you've stored the event durably. Your endpoint must acknowledge each delivery, whether or not it verifies the signature: the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2xx"]}," tells ","Ripple Custody (Vault)"," that the delivery succeeded. ","Ripple Custody (Vault)"," waits until each delivery succeeds or finally fails before it sends the next event, so acknowledge promptly. For how ","Ripple Custody (Vault)"," handles other responses, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/pt-br/products/custody/operations-and-maintenance/events-and-webhooks/webhooks-api#http-status-code-handling"},"children":["HTTP status code handling"]},"."]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Check your library"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Many webhook libraries implement only the symmetric HMAC scheme (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1"]},") of the Standard Webhooks specification. ","Ripple Custody (Vault)"," uses the asymmetric Ed25519 scheme (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1a"]},"). Make sure that your library supports ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1a"]},", or verify the signature yourself, as in the following examples."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following examples implement steps 2, 4, 5, and 7. Add duplicate detection, key refresh, and error handling to suit your service."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This example uses the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://cryptography.io/"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cryptography"]}]}," package."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import base64\nimport json\nimport time\n\nfrom cryptography.exceptions import InvalidSignature\nfrom cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey\n\nTOLERANCE_SECONDS = 5 * 60\n\n\ndef b64url_decode(value: str) -> bytes:\n    return base64.urlsafe_b64decode(value + \"=\" * (-len(value) % 4))\n\n\ndef verify_webhook(headers: dict, raw_body: bytes, jwks: dict, domain_id: str) -> bool:\n    msg_id = headers[\"webhook-id\"]\n    timestamp = headers[\"webhook-timestamp\"]\n\n    if abs(time.time() - int(timestamp)) > TOLERANCE_SECONDS:\n        return False\n\n    message = f\"{msg_id}.{timestamp}.\".encode() + raw_body\n    signatures = [\n        base64.b64decode(entry[len(\"v1a,\"):])\n        for entry in headers[\"webhook-signature\"].split(\" \")\n        if entry.startswith(\"v1a,\")\n    ]\n    keys = [\n        Ed25519PublicKey.from_public_bytes(b64url_decode(key[\"x\"]))\n        for key in jwks[\"keys\"]\n        if key.get(\"use\") == \"sig\" and key.get(\"crv\") == \"Ed25519\"\n    ]\n\n    for key in keys:\n        for signature in signatures:\n            try:\n                key.verify(signature, message)\n            except InvalidSignature:\n                continue\n            # The signature is valid: check that the event belongs to your domain.\n            return json.loads(raw_body).get(\"domainId\") == domain_id\n    return False\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This example uses the built-in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["node:crypto"]}," module."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"import { createPublicKey, verify } from \"node:crypto\";\n\nconst TOLERANCE_SECONDS = 5 * 60;\n\nexport function verifyWebhook(headers, rawBody, jwks, domainId) {\n  const msgId = headers[\"webhook-id\"];\n  const timestamp = headers[\"webhook-timestamp\"];\n\n  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > TOLERANCE_SECONDS) {\n    return false;\n  }\n\n  const message = Buffer.concat([Buffer.from(`${msgId}.${timestamp}.`), rawBody]);\n  const signatures = headers[\"webhook-signature\"]\n    .split(\" \")\n    .filter((entry) => entry.startsWith(\"v1a,\"))\n    .map((entry) => Buffer.from(entry.slice(\"v1a,\".length), \"base64\"));\n  const keys = jwks.keys\n    .filter((key) => key.use === \"sig\" && key.crv === \"Ed25519\")\n    .map((key) => createPublicKey({ key: { kty: \"OKP\", crv: \"Ed25519\", x: key.x }, format: \"jwk\" }));\n\n  const verified = keys.some((key) => signatures.some((signature) => verify(null, message, key, signature)));\n\n  // The signature is valid: check that the event belongs to your domain.\n  return verified && JSON.parse(rawBody.toString(\"utf8\")).domainId === domainId;\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rawBody"]}," must be a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Buffer"]}," that holds the unparsed request body. In Express, for example, use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["express.raw({ type: \"application/json\" })"]}," on the webhook route."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"key-rotation","__idx":5},"children":["Key rotation"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"scheduled-rotation","__idx":6},"children":["Scheduled rotation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ripple Custody (Vault)"," rotates the signing key automatically once a year:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key is published well in advance: from the previous rotation, or from the start for a new instance."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["At rotation, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key becomes the active key, and ","Ripple Custody (Vault)"," publishes a new ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For 30 days, the previous key stays in the key set with the status ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["retiring"]},", and each delivery carries two signatures, one from the previous key and one from the new key."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["After 30 days, the previous key stops signing and is removed from the key set."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Store the public keys in either of the following ways:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Cache the keys and refresh them every day."]}," Fetch the key set, cache it for up to 24 hours as the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Cache-Control"]}," header indicates, then fetch it again. Your endpoint picks up each new key automatically, and you don't need to take any action at rotation. This option also picks up an ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#emergency-rotation"},"children":["emergency rotation"]}," within a day."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Store the keys until the planned rotation."]}," Fetch the key set once, and use the active key's expiration time (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exp"]},") to schedule the next fetch, or to add the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key by hand, before the 30-day overlap ends. Rotation can happen later than ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exp"]},", so remove an old key only once it's no longer in the key set, not when its ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exp"]}," passes. You then fetch the key set about once a year. With this option, you don't pick up an emergency rotation until you fetch the key set again."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"emergency-rotation","__idx":7},"children":["Emergency rotation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If a signing key is compromised, the operator of your instance revokes it: Ripple for SaaS, or your platform team on-premises. The revoked key is removed from the key set immediately, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key starts signing at once, and there's no 30-day overlap."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your endpoint keeps trusting the revoked key until it refreshes the key set. Clients that respect the 24-hour cache lifetime stop trusting it within a day. If you're told about an emergency rotation, refresh the key set right away, and remove any key that you configured by hand."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"configure-signing-on-premises","__idx":8},"children":["Configure signing on-premises"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On-premises, the signing keys are stored encrypted under a master key. Configure the master key in your Helm values file:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kms.autoGenerate"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["If ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},", ","Ripple Custody (Vault)"," generates the master key. Default: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kms.master"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The master key, set inline."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kms.existingSecret.name"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kms.existingSecret.key"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The name of an existing Kubernetes Secret that holds the master key, and the key within that Secret. If you set an existing Secret, it takes precedence over the other options."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can't change the rotation period (12 months) or the overlap (30 days)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Signing uses a software KMS (KMS soft), not an HSM or a KMS Connect sidecar. For an air-gapped installation, make its image available in your private registry, like the other ","Ripple Custody (Vault)"," images."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"revoke-a-signing-key-on-premises","__idx":9},"children":["Revoke a signing key on-premises"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On-premises, you revoke a key through the Helm chart:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Add the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kid"]}," of the compromised key to the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhookSigning.revokedKids"]}," list in your values file."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["helm upgrade"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["At startup, ","Ripple Custody (Vault)"," removes every listed key. If the active key is listed, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key becomes active and ","Ripple Custody (Vault)"," creates a new ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you suspect that the key store itself is compromised, treat the master key that encrypts the signing keys as compromised too. Replace the master-key Secret, and list both the active and the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["next"]}," key in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webhookSigning.revokedKids"]},". ","Ripple Custody (Vault)"," then creates a new key that has never been published and makes it active immediately, so notify your webhook consumers to refresh their key sets."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"delivery-behavior","__idx":10},"children":["Delivery behavior"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If ","Ripple Custody (Vault)"," can't sign a delivery, for example because the signing service is temporarily unavailable, the delivery stays ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PENDING"]}," and is retried once signing is available again. These attempts don't count toward ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["maxRetries"]},". A separate process makes them, so these deliveries can arrive out of order, after events that were created later."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["While signing is unavailable, ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/pt-br/products/custody/operations-and-maintenance/events-and-webhooks/webhooks-api#test-a-webhook-channel"},"children":["Test a webhook channel"]}," returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["503 Service Unavailable"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For HTTPS webhook URLs, ","Ripple Custody (Vault)"," uses TLS 1.2 or 1.3, validates the server certificate against the standard trust store, and verifies the hostname. You can't add a custom certificate authority to the trust store, as for other ","Ripple Custody (Vault)"," components, so your endpoint's certificate must chain to a publicly trusted certificate authority."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"related-topics","__idx":11},"children":["Related topics"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/pt-br/products/custody/operations-and-maintenance/events-and-webhooks/webhooks-api"},"children":["Manage webhooks with the API"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/pt-br/products/custody/operations-and-maintenance/events-and-webhooks/webhooks-ui"},"children":["Manage webhooks in the UI"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/pt-br/products/custody/reference/events-and-webhooks/event-payload-reference"},"children":["Event payload reference"]}]}]}]},"headings":[{"value":"Verify webhook signatures","id":"verify-webhook-signatures","depth":1},{"value":"How signing works","id":"how-signing-works","depth":2},{"value":"Signature headers","id":"signature-headers","depth":2},{"value":"Get the public keys","id":"get-the-public-keys","depth":2},{"value":"Verify a delivery","id":"verify-a-delivery","depth":2},{"value":"Key rotation","id":"key-rotation","depth":2},{"value":"Scheduled rotation","id":"scheduled-rotation","depth":3},{"value":"Emergency rotation","id":"emergency-rotation","depth":3},{"value":"Configure signing on-premises","id":"configure-signing-on-premises","depth":3},{"value":"Revoke a signing key on-premises","id":"revoke-a-signing-key-on-premises","depth":3},{"value":"Delivery behavior","id":"delivery-behavior","depth":2},{"value":"Related topics","id":"related-topics","depth":2}],"frontmatter":{"seo":{"title":"Verify webhook signatures"}},"lastModified":"2026-11-30T18:25:15.000Z","isTranslationFallback":true,"pagePropGetterError":{"message":"","name":""}},"slug":"/pt-br/products/custody/operations-and-maintenance/events-and-webhooks/verify-webhook-signatures","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}