From e3f8f371a7ab5e89139822a16f563b977196fefe Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 15 Aug 2021 21:54:24 +0000 Subject: [PATCH] Use the existing VAPID key generation --- src/Model/Subscription.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Model/Subscription.php b/src/Model/Subscription.php index 43bf2ae551..e83bb919c1 100644 --- a/src/Model/Subscription.php +++ b/src/Model/Subscription.php @@ -31,6 +31,7 @@ use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Util\Crypto; +use Minishlink\WebPush\VAPID; class Subscription { @@ -107,8 +108,8 @@ class Subscription private static function getKeyPair(): array { $keypair = DI::config()->get('system', 'ec_keypair'); - if (empty($keypair)) { - $keypair = Crypto::newECKeypair(); + if (empty($keypair['publicKey']) || empty($keypair['privateKey'])) { + $keypair = VAPID::createVapidKeys(); DI::config()->set('system', 'ec_keypair', $keypair); } return $keypair; @@ -122,7 +123,7 @@ class Subscription public static function getPublicVapidKey(): string { $keypair = self::getKeyPair(); - return $keypair['vapid-public']; + return $keypair['publicKey']; } /** @@ -133,7 +134,7 @@ class Subscription public static function getPrivateVapidKey(): string { $keypair = self::getKeyPair(); - return $keypair['vapid-private']; + return $keypair['privateKey']; } /**