我正在使用 Amazon Simple Notification Service (Amazon SNS) 向 HTTPS 或 HTTP 端點發送通知。我想要預防詐騙攻擊,我該如何確認端點收到的 Amazon SNS 訊息的真實性?
解決方案
若要確認 Amazon SNS 通知的真實性,最好使用憑證型簽章驗證。如需說明,請參閱《Amazon SNS 開發人員指南》中的驗證 Amazon SNS 訊息的簽章 。
為了防止詐騙攻擊,請務必在確認 Amazon SNS 訊息簽章時執行下列操作:
訊息內文範例
以下是從 Amazon SNS 傳送的訊息承載字串範例:
{
"Type" : "Notification",
"MessageId" : "e1f2a232-e8ce-5f0a-b5d3-fbebXXXXXXXX",
"TopicArn" : "arn:aws:sns:us-east-1:XXXXXXXX:SNSHTTPSTEST",
"Subject" : "Test",
"Message" : "TestHTTPS",
"Timestamp" : "2021-10-07T18:55:19.793Z",
"SignatureVersion" : "1",
"Signature" : "VetoDxbYMh0Ii/87swLEGZt6FB0ZzGRjlW5BiVmKK1OLiV8B8NaVlADa6ThbWd1s89A4WX1WQwJMayucR8oYzEcWEH6//VxXCMQxWD80rG/NrxLeoyas4IHXhneiqBglLXh/R9nDZcMAmjPETOW61N8AnLh7nQ27O8Z+HCwY1wjxiShwElH5/+2cZvwCoD+oka3Gweu2tQyZAA9ergdJmXA9ukVnfieEEinhb8wuaemihvKLwGOTVoW/9IRMnixrDsOYOzFt+PXYuKQ6KGXpzV8U/fuJDsWiFa/lPHWw9pqfeA8lqUJwrgdbBS9vjOJIL+u2c49kzlei8zCelK3n7w==",
"SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-7ff5318490ec183fbaddaa2aXXXXXXXX.pem",
"UnsubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:XXXXXXXX:SNSHTTPSTEST:b5ab2db8-7775-4852-bd1a-2520XXXXXXXX",
"MessageAttributes" : {
"surname" : {"Type":"String","Value":"SNSHTTPSTest"}
}
}
如需 Amazon SNS 使用之訊息格式的詳細資訊,請參閱解析訊息格式。
相關資訊
散發到 HTTP/S 端點
使用 AWS Lamba 搭配 Amazon SNS
Amazon SNS 的 IP 地址範圍是多少?