summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib/magicenvelope.php
diff options
context:
space:
mode:
authorJames Walker <walkah@walkah.net>2010-02-26 04:07:58 -0500
committerJames Walker <walkah@walkah.net>2010-02-26 04:07:58 -0500
commitab8bb4d79e5f267323440b8cee01458b393ce2d1 (patch)
treebc7bd1f0fe849d1b3a932311dd40b6b538ea40ae /plugins/OStatus/lib/magicenvelope.php
parentd1256b547f5f4f02ddc51a5fe2146dbde52aac53 (diff)
more cleanup
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(