Webhook validation

(Ashwini S) #1


I used webhook validation code which was working fine but now suddenly stooped working.  Can any one let me know is there any changes in webhook validation code.

Please see the below dotnet code for validation

            string message = Request.Content.ReadAsStringAsync().Result; //Code to get request body

            IEnumerable<string> headerValues = Request.Headers.GetValues("X-Request-Signature-Sha-256"); //Code to get X-Request-Signature-Sha-256 value from headwe.

            var signature = headerValues.FirstOrDefault();

            ASCIIEncoding encoding = new ASCIIEncoding();

            byte[] keyByte = encoding.GetBytes(WSwebhookKey);

            byte[] messageBytes = encoding.GetBytes(message);

            HMACSHA256 hmacsha256 = new HMACSHA256(keyByte);

            byte[] hashedMessage = hmacsha256.ComputeHash(messageBytes);

            var hashKey = signature != null && signature.ToLower().Equals(ByteToString(hashedMessage).ToLower());

Where WSwebhookKey is webhook secret key.
always getting hashKey value as false.

Ashwini S