2017-07-03 114 views
1

我試圖通過SNS(簡單通知服務)通過http(s)處理一些亞馬遜SES(簡單電子郵件服務)消息到我們的服務器。亞馬遜SNS確認

但是,我無法獲得我們的域名確認。什麼是正確的方法來做到這一點?我已經嘗試過'sns-validator'npm模塊,但他說這條消息缺少必需的密鑰。

我們使用Node.JS和express。解析驗證消息的正確方法是什麼?

validator.validate(req.headers, function (err, message) { 
     if (err) { 
      console.error(err); 
      return; 
     } 

     if (message['Type'] === 'SubscriptionConfirmation') { 
      https.get(message['SubscribeURL'], function (res) { 
      // You have confirmed your endpoint subscription 
      console.log("confirmed"); 
      }); 
     } 
    }); 

編輯: 我已經登錄了req,我只看到了亞馬遜的報頭req.headers

accept-encoding:"gzip,deflate" 
content-length:"1517" 
content-type:"text/plain; charset=UTF-8" 
host:"[nrgokurl].ngrok.io" 
user-agent:"Amazon Simple Notification Service Agent" 
x-amz-sns-message-id:"[id]" 
x-amz-sns-message-type:"SubscriptionConfirmation" 
x-amz-sns-topic-arn:"arn:[arn]:complaints" 
x-forwarded-for:"54.240.197.14" 
x-forwarded-proto:"https" 

我沒有數據作爲認購http://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html#SendMessageToHttp.prepare 我在哪裏可以找到這些數據?

回答