Skip to content

Commit

Permalink
Log some values
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Apr 12, 2024
1 parent 929005e commit ea67977
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/FaluSdk/Webhooks/WebhookUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public static void ValidateSignature(byte[] payload, string signature, string se
var actual = ParseSignature(signature);
var actualTimestamp = actual["t"].FirstOrDefault();
var expected = ComputeSignature(secret, actualTimestamp, payload);
Console.WriteLine($"Signature: {signature}");
Console.WriteLine($"Actual: {actual}");
Console.WriteLine($"actual[\"t\"]: {actual["t"]}");
Console.WriteLine($"actual[\"sha256\"]: {actual["sha256"]}");
Console.WriteLine($"Expected: {expected}");

if (!IsSignaturePresent(expected, actual["sha256"]))
{
Expand Down Expand Up @@ -73,6 +78,10 @@ private static string ComputeSignature(string secret, string? timestamp, byte[]
{
var secretBytes = Encoding.UTF8.GetBytes(secret);
var payloadBytes = Encoding.UTF8.GetBytes($"{timestamp}.").Concat(payload).ToArray();
Console.WriteLine($"Secret: {secret}");
Console.WriteLine($"Timestamp: {timestamp}");
Console.WriteLine($"Payload: '{Convert.ToBase64String(payload)}'");
Console.WriteLine($"PayloadBytes: '{Convert.ToBase64String(payloadBytes)}'");

using var hasher = new HMACSHA256(secretBytes);
var hash = hasher.ComputeHash(payloadBytes);
Expand Down

0 comments on commit ea67977

Please sign in to comment.