Skip to content

Commit 588dda1

Browse files
committed
Fix SNS signature verification to support both legacy and current path formats
1 parent fff6ce3 commit 588dda1

File tree

1 file changed

+4
-1
lines changed
  • supabase/functions/webhook-aws-ses-notifications

1 file changed

+4
-1
lines changed

supabase/functions/webhook-aws-ses-notifications/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ async function verifySnsSignature(message: SnsMessage): Promise<boolean> {
233233
const host = certUrl.host.toLowerCase();
234234
if (!certUrl.protocol.startsWith("https")) return false;
235235
if (!host.endsWith("amazonaws.com")) return false;
236-
if (!certUrl.pathname.includes("/sns.")) return false;
236+
const path = certUrl.pathname.toLowerCase();
237+
const isLegacy = path.includes("/sns.");
238+
const isCurrent = path.includes("simplenotificationservice-");
239+
if (!isLegacy && !isCurrent) return false;
237240

238241
const certPem = await fetch(certUrl.toString()).then((res) => res.text());
239242
const certBytes = pemToArrayBuffer(certPem);

0 commit comments

Comments
 (0)