Webhook Signature Validation
To ensure the security and integrity of webhook notifications, Ripio signs the request payload using the ECDSA (Elliptic Curve Digital Signature Algorithm) with the P-256 curve. This allows you to verify that the webhook payload was sent by Ripio and has not been tampered with during transmission.Overview of Signature Validation
Webhook requests from Ripio will include anX-Signature-Ecdsa-Sha256 header. This header contains the ECDSA signature of the request payload. You will need to use Ripio’s public key to verify this signature.
Validating the Signature: Step-by-Step Guide
-
Retrieve the Signature Header:
Extract the value of the
X-Signature-Ecdsa-Sha256header from the incoming webhook request. The signature is Base64 encoded. - Extract the Raw Payload: Get the raw JSON payload from the body of the webhook request. It is crucial to use the raw, unmodified payload as it was received.
- Verify the Signature: Using Ripio’s public key for the P-256 curve, verify the signature against the raw payload. If the signature is valid, the webhook is authentic.
Important Notes for Signature Validation
- Exact Payload: Ensure that the payload used for verification is exactly as it was sent by Ripio. Any modification will cause the verification to fail. The JSON payload must be serialized into a compact string, with no whitespace after separators (e.g.,
{"key":"value"}instead of{"key": "value"}). - Secure Public Key Storage: Store Ripio’s public key securely.
- Reject Invalid Requests: Always reject requests with missing or invalid signatures.
Webhook Events
For details on specific webhook events and their payload structures, please refer to the following pages:Configuring Your Webhook Endpoint
To receive webhook notifications, you need to configure a publicly accessible HTTPS URL endpoint in your Ripio partner settings. Ripio will send POST requests to this URL with a JSON payload. Key considerations for your endpoint:- HTTPS: Your endpoint URL must use HTTPS.
- Respond Quickly: Your endpoint should acknowledge receipt of the webhook by returning a
2xxHTTP status code (e.g.,200 OKor202 Accepted) as quickly as possible, ideally within 10 seconds as per Ripio’s guidelines. - Asynchronous Processing: For any time-consuming processing of the webhook data, perform it asynchronously (e.g., using a message queue) to ensure your endpoint responds promptly.
- Idempotency: Design your webhook handler to be idempotent. This means that processing the same event multiple times should not result in duplicated actions or inconsistent state, as network issues or retries might cause a webhook to be delivered more than once.