]> git.mxchange.org Git - friendica.git/commitdiff
Diaspora: Avoid warning "supplied key param cannot be coerced into a public key"
authorMichael <heluecht@pirati.ca>
Fri, 9 Mar 2018 05:31:13 +0000 (05:31 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 9 Mar 2018 05:31:13 +0000 (05:31 +0000)
src/Protocol/Diaspora.php

index 384a019587f4e8282e5f14def77c467fce1a4de0..ffa47b16884cbe6e9009be1683ddd2f441b1ea9e 100644 (file)
@@ -222,10 +222,14 @@ class Diaspora
                $signable_data = $msg.".".base64url_encode($type).".".base64url_encode($encoding).".".base64url_encode($alg);
 
                $key = self::key($handle);
+               if ($key == '') {
+                       logger("Couldn't get a key for handle " . $handle . ". Discarding.");
+                       return false;
+               }
 
                $verify = Crypto::rsaVerify($signable_data, $sig, $key);
                if (!$verify) {
-                       logger('Message did not verify. Discarding.');
+                       logger('Message from ' . $handle . ' did not verify. Discarding.');
                        return false;
                }
 
@@ -321,6 +325,11 @@ class Diaspora
                // Get the senders' public key
                $key_id = $base->sig[0]->attributes()->key_id[0];
                $author_addr = base64_decode($key_id);
+               if ($author_addr == '') {
+                       logger('No author could be decoded. Discarding. Message: ' . $xml);
+                       System::httpExit(400);
+               }
+
                $key = self::key($author_addr);
 
                $verify = Crypto::rsaVerify($signed_data, $signature, $key);