Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X-Hub-Signature does not match blob signature #45

Open
almamlaka opened this issue Jan 16, 2020 · 2 comments
Open

X-Hub-Signature does not match blob signature #45

almamlaka opened this issue Jan 16, 2020 · 2 comments

Comments

@almamlaka
Copy link

almamlaka commented Jan 16, 2020

using my own function works but it crash with github-webhook-handler:

    const createComparisonSignature = (body) => {
      const hmac = crypto.createHmac('sha1', process.env.GITHUB_SECRET);
      const self_signature = hmac.update(JSON.stringify(body)).digest('hex');
      return `sha1=${self_signature}`; // shape in GitHub header
    }
    const compareSignatures = (signature, comparison_signature) => {
      const source = Buffer.from(signature);
      const comparison = Buffer.from(comparison_signature);
      return crypto.timingSafeEqual(source, comparison); // constant time comparison
    }
    const { headers, body } = req;
    const signature = headers['x-hub-signature'];
    const comparison_signature = createComparisonSignature(req.body);
    if (!compareSignatures(signature, comparison_signature)) {
      return res.status(401).send('Mismatched signatures');
    } else {
      console.log("signature match")
      const { action, ...payload } = body;
      req.event_type = headers['x-github-event']; // one of: https://developer.github.com/v3/activity/events/types/ 
      req.action = action;
      req.payload = payload;
      next();
    }
    return next()

please let me know if there is any solution

@twesix
Copy link

twesix commented Jul 16, 2020

I have the same issue too. But the project seems to be obsoleted because the issue exists for a long time and there is no response from the maintaining team.

@Rem486
Copy link

Rem486 commented Jul 22, 2020

I have forked a repository git-webhook-handler, I am using it. You can try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@twesix @Rem486 @almamlaka and others