]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/lib/magicenvelope.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / OStatus / lib / magicenvelope.php
index 1d18d6934a49459bdbe928777577ca6904dc715c..09b0f452f9f6ffee98f564d620334a4b48a0493d 100644 (file)
@@ -76,6 +76,10 @@ class MagicEnvelope
             $magicsig = new Magicsig();
             $magicsig->user_id = $profile->id;
             $magicsig->importKeys($keypair);
+            // save the public key for this profile in our database.
+            // TODO: If the profile generates a new key remotely, we must be able to replace
+            //       this (of course after callback-verification).
+            $magicsig->insert();
         } elseif (!$magicsig instanceof Magicsig) { // No discovery request, so we'll give up.
             throw new ServerException(sprintf('No public key found for profile (id==%d)', $profile->id));
         }
@@ -188,7 +192,6 @@ class MagicEnvelope
         $xs->elementEnd('me:env');
 
         $string =  $xs->getString();
-        common_debug('MagicEnvelope XML: ' . $string);
         return $string;
     }
 
@@ -271,19 +274,19 @@ class MagicEnvelope
     public function verify(Profile $profile)
     {
         if ($this->alg != 'RSA-SHA256') {
-            common_log(LOG_DEBUG, "Salmon error: bad algorithm");
+            common_debug("Salmon error: bad algorithm");
             return false;
         }
 
         if ($this->encoding != self::ENCODING) {
-            common_log(LOG_DEBUG, "Salmon error: bad encoding");
+            common_debug("Salmon error: bad encoding");
             return false;
         }
 
         try {
             $magicsig = $this->getKeyPair($profile, true);    // Do discovery too if necessary
         } catch (Exception $e) {
-            common_log(LOG_DEBUG, "Salmon error: ".$e->getMessage());
+            common_debug("Salmon error: ".$e->getMessage());
             return false;
         }