我试图在GitHub API和AppCenter API之间编写代理服务,当我尝试重新路由标准GitHub API消息时,我收到“签名无效”响应。 这是我要发送的内容:
{
"ref": "refs/heads/xxxx",
"before": "xxxxxxxxxxxxx",
"after": "xxxxxxxxxxxxx",
"created": false,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/xxxxx",
"commits": [{
"content": "xxxx"
}],
"head_commit": {
"content": "xxxx"
},
"repository": {
"content": "xxxx"
},
"pusher": {
"content": "xxxx"
},
"organization": {
"content": "xxxx"
},
"sender": {
"content": "xxxx"
}
}
AppCenter的终结点是:
https://api.appcenter.ms/v0.1/public/apps/xxxxxxxxxxx/hooks
请求的标头是:
{
"content-type": "application/json",
"User-Agent": "GitHub-Hookshot/xxxxxxxx",
"X-GitHub-Delivery": "xxxxxxxxxxxxxx",
"X-GitHub-Event": "push",
"X-Hub-Signature": "sha1=xxxxxxxxxxx"
}
这是我得到的答复:
{
"id": "xxxxxxxxxxxxxxxx",
"message": "Signature is invalid"
}
我尚未收到AppCenter的明智答复,希望有人已经有类似的经验并可以回答。 谢谢
答案 0 :(得分:1)
我认为问题在于X-Hub-Signature
的价值。从Validating payloads from Github起,Github在有效载荷数据和您在存储库的webhook部分中输入的秘密字符串之间使用HMAC SHA1:
签名格式(不带括号):
sha1={HMAC-SHA1(secret, payload)}
一些计算签名的示例: