From 51b55b5eccea473cd0243ff648418c039f834f7f Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 18 Mar 2022 23:46:53 +0100 Subject: [PATCH] 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);