PrepareEncryptionTask: verify client key before entering task

this ensures that whoever's giving invalid keys to the task gets properly blamed
This commit is contained in:
Dylan K. Taylor
2025-10-04 12:48:29 +01:00
parent 24567dac54
commit 05a71d8cc5

View File

@@ -51,6 +51,9 @@ class PrepareEncryptionTask extends AsyncTask{
private string $clientPub,
\Closure $onCompletion
){
//make sure the key is valid before we break the stack trace
//TODO: maybe in the future we should require OpenSSLAsymmetricKey here instead of string
JwtUtils::parseDerPublicKey($this->clientPub);
if(self::$SERVER_PRIVATE_KEY === null){
$serverPrivateKey = openssl_pkey_new(["ec" => ["curve_name" => "secp384r1"]]);
if($serverPrivateKey === false){