1
我在Uber沙箱中遇到了NodeJS和WebHook測試的一些問題。我能夠接受correcty POST響應,但安全檢查(X-尤伯杯簽名)永遠是錯的..Uber webhook簽名問題nodeJs(hmac)
module.exports = {
myWebService: function(req, res) {
const hmac = crypto.createHmac('sha256','<MYSECRET>');
var hash = hmac.update(JSON.stringify(req.body)).digest('hex');
//Those values are always different..
console.log("Constructed hash : " + hash +"\n");
console.log("Received hash : " + req.header('X-Uber-Signature') + "\n");
JSON.stringify(req.body)內容:
{"event_id":"08db06df-559a-457a-ba92-3c8380bb7ec7","resource_href":"https://sandbox-api.uber.com/v1/requests/8f5cc257-cfdf-4654-9acd-085aae740107","meta":{"status":"arriving","rider_id":"8IMl8ulC-yJTqkbsq5g4HuyuYeRQ5b5aSsmLt2vpjl6H8Fk_JPz_5AZYj4ERi6M7MagmrJtPM7L_rAnHLgO0qLgGtpD8Lg32rnGTEUkWHAbPjDZIl0-X91PrrujPY_IYGA==","user_id":"ecb2e871-b768-4f76-bfa9-8bc253bced0e","resource_id":"8f5cc257-cfdf-4654-9acd-085aae740107"},"event_type":"all_trips.status_changed","event_time":1508163555}
我試過很多(多)轉換此字符串,但沒有工作,如果任何人有一個想法,這將是極大的讚賞..謝謝
感謝您的回答,所以目前我們無法使用Node.js驗證優步簽名?如果我明白了,我的_req_值不包含服務器端存在的反斜槓? –