Check keyId against actor's public key

merge-requests/5/head
Terence Eden 2024-03-07 21:40:50 +00:00
rodzic c2f14fc910
commit 3231a4fc52
1 zmienionych plików z 35 dodań i 25 usunięć

Wyświetl plik

@ -1555,6 +1555,14 @@ HTML;
$userData = getDataFromURl( $publicKeyURL );
$publicKey = $userData["publicKey"]["publicKeyPem"];
// Check that the actor's key is the same as the key used to sign the message
// Get the actor's public key
$actorData = getDataFromURl( $body["actor"] );
$actorPublicKey = $actorData["publicKey"]["publicKeyPem"];
if ( $publicKey != $actorPublicKey ) {
$verified = false;
} else {
// Get the remaining parts
$signature = base64_decode( $signatureParts["signature"] );
$algorithm = $signatureParts["algorithm"];
@ -1583,6 +1591,7 @@ HTML;
} else {
$verified = null;
}
}
// Filename for the log
$filename = "{$timestamp}.{$type}.Signature.". json_encode( $verified ) . ".txt";
@ -1595,7 +1604,8 @@ HTML;
"Calculated signatureString:\n" . print_r( $signatureString, true ) . "\n\n" .
"Calculated algorithm:\n" . print_r( $algorithm, true ) . "\n\n" .
"publicKeyURL:\n" . print_r( $publicKeyURL, true ) . "\n\n" .
"publicKey:\n" . print_r( $publicKey, true ) . "\n"
"publicKey:\n" . print_r( $publicKey, true ) . "\n\n" .
"actorPublicKey:\n" . print_r( $actorPublicKey, true ) . "\n"
);
return $verified;