Webhook's signature verification
To ensure the authenticity and integrity of webhook requests, Cakewalk signs each payload with a cryptographic signature. When your application receives a webhook, it must verify this signature using the public key provided by Cakewalk. The signature is included in the X-SIGNATURE header, and it is generated using the SHA hash of the raw request body, signed with Cakewalk’s private RSA key.
Your server retrieves the corresponding public key from the https://open-api.getcakewalk.io/api/Keys endpoint, using your API credentials for authorization. By verifying the signature against the raw payload using this public key, your application can confirm that the request was not tampered with and was genuinely sent by Cakewalk.
📋 Prepare configuration options
1. Define a configuration class:
public class CakewalkApiOptions
{
public const string SectionName = "CakewalkApi";
public string ApiKey { get; set; } = string.Empty;
public string ApiSecret { get; set; } = string.Empty;
public string PublicKeyEndpoint { get; set; } = "<https://open-api.getcakewalk.io/api/Keys>";
}
2. Register configuration in Program.cs or Startup.cs:
Program.cs or Startup.cs:builder.Services.Configure<CakewalkApiOptions>(
builder.Configuration.GetSection(CakewalkApiOptions.SectionName));
✅ Environment variables like CakewalkApi__ApiKey will automatically be bound if you use double underscores (__) in the name.
🔐 Signature Verification with Remote Public Key
SignatureService Implementation:
SignatureService Implementation:🧪 Interface and Registration
Interface:
Dependency Injection in Program.cs:
Program.cs:🛡️ Implement the webhook endpoint with the validation logic
✅ Sample appsettings.json or environment variables
appsettings.json or environment variablesOr via environment variables:
🧱 Project Structure:
CakewalkApiProperties - 📋 Configuration Class
CakewalkApiProperties - 📋 Configuration ClassSignatureService - 🔐 Signature Verification with Remote Public Key
SignatureService - 🔐 Signature Verification with Remote Public KeyWebhookController - 🛡️ Implement the webhook endpoint with the validation logic
WebhookController - 🛡️ Implement the webhook endpoint with the validation logicapplication.properties Example
application.properties ExampleYou can override via environment variables:
Dependencies (pom.xml)
pom.xml)Make sure you have these dependencies:
Expected test payload
When you create the webhook in cakewalk, the webhook URL will be validated by sending automatically the following test event payload:
Last updated
Was this helpful?