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.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php
index 81f4609c5..457c0fba2 100644
--- a/plugins/OStatus/lib/magicenvelope.php
+++ b/plugins/OStatus/lib/magicenvelope.php
@@ -50,7 +50,20 @@ class MagicEnvelope
public function getKeyPair($signer_uri)
{
- return 'RSA.79_L2gq-TD72Nsb5yGS0r9stLLpJZF5AHXyxzWmQmlqKl276LEJEs8CppcerLcR90MbYQUwt-SX9slx40Yq3vA==.AQAB.AR-jo5KMfSISmDAT2iMs2_vNFgWRjl5rbJVvA0SpGIEWyPdCGxlPtCbTexp8-0ZEIe8a4SyjatBECH5hxgMTpw==';
+ $disco = new Discovery();
+
+ 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');
}
@@ -59,10 +72,14 @@ class MagicEnvelope
$signer_uri = $this->normalizeUser($signer_uri);
if (!$this->checkAuthor($text, $signer_uri)) {
- return false;
+ 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(