Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

HMAC Policy - Validate Request from Client

Hi All,

Issue: In the Trace, the HMAC policy is failing  with hmac.error = Unresolved variable : sha. {"fault":{"faultstring":"Unresolved variable : sha","detail":{"errorcode":"entities.UnresolvedVariable"}}}. I'm assuming sha is a variable set by the HMAC policy itself, as it is not referenced anywhere in my policies. Is this error related to how the request content is coming through? And if so, how do I go about determining what needs to be fixed/tweaked? Please let me know what you all think. I've included some additional info below for reference.

 

Background: I have a webhook set up in GitHub which utilizes HMAC Validation with Apigee. Using the same secret in GitHub and Apigee to encode/decode. GitHub is sending header 'X-Hub-Signature-256', the value of the header is populated using sha-256 and the secret key to hash the request content. Below is my HMAC policy code. I've tried setting the IgnoreUnresolvedVariables tag to true, but then my verification values don't match.


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<HMAC name="HMAC-1">
<DisplayName>HMAC Validate Request Content</DisplayName>
<Algorithm>SHA-256</Algorithm>
<Message ref="request.content"/>
<SecretKey ref="private.secretkey"/>
<VerificationValue encoding="base64" ref="request.header.X-Hub-Signature-256"/>
<Output>hmac_value</Output>
</HMAC>

Solved Solved
0 9 2,729
1 ACCEPTED SOLUTION

Hi All,

After performing some more troubleshooting, I found out what the issue was(GitHub side). In the GitHub Webhook configuration, the content type selected was application/json, this was causing the error. Once I changed it to application/x-www-form-urlencoded, the HMAC policy began working as expected.

View solution in original post

9 REPLIES 9