Skip to content

Commit

Permalink
Merge pull request #1 from pyrou/patch-1
Browse files Browse the repository at this point in the history
Cache SNS signing certificate
  • Loading branch information
introwit authored Mar 21, 2022
2 parents bd624ae + 8684d05 commit 7499bfa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Controllers/AwsSnsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -14,7 +15,11 @@ public function __invoke()
{
$message = Message::fromRawPostData();

$validator = new MessageValidator();
$validator = new MessageValidator(function ($certUrl) {
return Cache::rememberForever($certUrl, function () use ($certUrl) {
return file_get_contents($certUrl);
});
});

try {
$validator->validate($message);
Expand Down

0 comments on commit 7499bfa

Please sign in to comment.