Skip to content

Commit

Permalink
By creating new public/private key clear database with registered ser…
Browse files Browse the repository at this point in the history
…vice worker
  • Loading branch information
Cyperghost committed Feb 23, 2024
1 parent f4f354e commit 8ce4cc4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use wcf\system\io\HttpFactory;
use wcf\system\registry\RegistryHandler;
use wcf\system\SingletonFactory;
use wcf\system\WCF;

/**
* @author Olaf Braun
Expand Down Expand Up @@ -50,7 +51,7 @@ public function updateKeys(): void
private function createNewKeys(): void
{
$jwk = JWKFactory::createECKey(Encryption::CURVE_ALGORITHM);
$binaryPublicKey = Util::serializePublicKey($jwk->get('x'), $jwk->get('y'));
$binaryPublicKey = Util::serializePublicKey($jwk);
$binaryPrivateKey = \str_pad(
Base64UrlSafe::decode($jwk->get('d'), true),
VAPID::PRIVATE_KEY_LENGTH,
Expand All @@ -68,6 +69,11 @@ private function createNewKeys(): void
self::REGISTRY_KEY,
\hash('sha256', $base64PrivateKey)
);

// Previous client keys are no longer valid
$sql = "DELETE FROM wcf1_service_worker";
$statement = WCF::getDB()->prepare($sql);
$statement->execute();
}

/**
Expand Down

0 comments on commit 8ce4cc4

Please sign in to comment.