Catch a previously uncaught exception and add some additional debug logs for signature verification
This commit is contained in:
parent
9cbeac5695
commit
ddc4a7d2ff
@ -156,17 +156,31 @@ class MagicEnvelope
|
||||
public function verify($env)
|
||||
{
|
||||
if ($env['alg'] != 'RSA-SHA256') {
|
||||
common_log(LOG_DEBUG, "Salmon error: bad algorithm");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($env['encoding'] != MagicEnvelope::ENCODING) {
|
||||
common_log(LOG_DEBUG, "Salmon error: bad encoding");
|
||||
return false;
|
||||
}
|
||||
|
||||
$text = base64_decode($env['data']);
|
||||
$signer_uri = $this->getAuthor($text);
|
||||
|
||||
$verifier = Magicsig::fromString($this->getKeyPair($signer_uri));
|
||||
try {
|
||||
$keypair = $this->getKeyPair($signer_uri);
|
||||
} catch (Exception $e) {
|
||||
common_log(LOG_DEBUG, "Salmon error: ".$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
$verifier = Magicsig::fromString($keypair);
|
||||
|
||||
if (!$verifier) {
|
||||
common_log(LOG_DEBUG, "Salmon error: unable to parse keypair");
|
||||
return false;
|
||||
}
|
||||
|
||||
return $verifier->verify($env['data'], $env['sig']);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user