summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib/magicenvelope.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/OStatus/lib/magicenvelope.php')
-rw-r--r--plugins/OStatus/lib/magicenvelope.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php
index c642af548..457c0fba2 100644
--- a/plugins/OStatus/lib/magicenvelope.php
+++ b/plugins/OStatus/lib/magicenvelope.php
@@ -52,12 +52,17 @@ class MagicEnvelope
{
$disco = new Discovery();
- $xrd = $disco->lookup($signer_uri);
- if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
- list($type, $keypair) = explode(';', $link['href']);
- return $keypair;
+ try {
+ $xrd = $disco->lookup($signer_uri);
+ } catch (Exception $e) {
+ return false;
+ }
+ if ($xrd->links) {
+ if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
+ list($type, $keypair) = explode(';', $link['href']);
+ return $keypair;
+ }
}
-
throw new Exception('Unable to locate signer public key');
}
@@ -70,7 +75,11 @@ class MagicEnvelope
throw new Exception("Unable to determine entry author.");
}
- $signature_alg = Magicsig::fromString($this->getKeyPair($signer_uri));
+ $keypair = $this->getKeyPair($signer_uri);
+ if (!$keypair) {
+ throw new Exception("Unable to retrive keypair for ". $signer_uri);
+ }
+ $signature_alg = Magicsig::fromString($keypair);
$armored_text = base64_encode($text);
return array(