From 51b55b5eccea473cd0243ff648418c039f834f7f Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 18 Mar 2022 23:46:53 +0100 Subject: [PATCH 1/2] Cache SNS signing certificate --- src/Controllers/AwsSnsController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Controllers/AwsSnsController.php b/src/Controllers/AwsSnsController.php index c9cf9bc..e01cddc 100644 --- a/src/Controllers/AwsSnsController.php +++ b/src/Controllers/AwsSnsController.php @@ -5,6 +5,7 @@ use Aws\Sns\Exception\InvalidSnsMessageException; use Aws\Sns\Message; use Aws\Sns\MessageValidator; +use Illuminate\Support\Facades\Cache; use JoggApp\AwsSns\Events\SnsMessageReceived; use JoggApp\AwsSns\Events\SnsTopicSubscriptionConfirmed; @@ -14,7 +15,11 @@ public function __invoke() { $message = Message::fromRawPostData(); - $validator = new MessageValidator(); + $validator = new MessageValidator(function ($certUrl) { + return Cache::rememberForever($certUrl, function ($certUrl) { + return file_get_contents($certUrl); + }); + }); try { $validator->validate($message); From 8684d059c9dce3af1254d7eadbe447f2b544993a Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 19 Mar 2022 00:05:26 +0100 Subject: [PATCH 2/2] Update AwsSnsController.php --- src/Controllers/AwsSnsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/AwsSnsController.php b/src/Controllers/AwsSnsController.php index e01cddc..9561d0c 100644 --- a/src/Controllers/AwsSnsController.php +++ b/src/Controllers/AwsSnsController.php @@ -16,7 +16,7 @@ public function __invoke() $message = Message::fromRawPostData(); $validator = new MessageValidator(function ($certUrl) { - return Cache::rememberForever($certUrl, function ($certUrl) { + return Cache::rememberForever($certUrl, function () use ($certUrl) { return file_get_contents($certUrl); }); });