diff options
author | James Walker <walkah@walkah.net> | 2010-03-04 01:46:34 -0500 |
---|---|---|
committer | James Walker <walkah@walkah.net> | 2010-03-04 01:46:34 -0500 |
commit | ddc4a7d2ffde5a925c2cfe7b57e51cd0b2cf0153 (patch) | |
tree | 6cdca9d3c2e4da7d43122bc913339654cab99aa4 /plugins/OStatus/lib | |
parent | 9cbeac5695454af0c2fa1a8068b45698da962064 (diff) |
Catch a previously uncaught exception and add some additional debug logs for signature verification
Diffstat (limited to 'plugins/OStatus/lib')
-rw-r--r-- | plugins/OStatus/lib/magicenvelope.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php index 230d81ba1..fb8c57c71 100644 --- a/plugins/OStatus/lib/magicenvelope.php +++ b/plugins/OStatus/lib/magicenvelope.php @@ -156,18 +156,32 @@ 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']); } |