]> git.mxchange.org Git - friendica.git/commitdiff
Avoid transmitting a deletion message when we don't have a key
authorMichael <heluecht@pirati.ca>
Mon, 4 Mar 2019 06:52:43 +0000 (06:52 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 4 Mar 2019 06:52:43 +0000 (06:52 +0000)
src/Protocol/ActivityPub/Transmitter.php
src/Util/Crypto.php

index 7d33fb2dc54713cdafdcd7a1bbe6713a811764e6..f2df43e854ffef5af74e993045f8257309b0f986 100644 (file)
@@ -1209,6 +1209,16 @@ class Transmitter
        {
                $owner = User::getOwnerDataById($uid);
 
+               if (empty($owner)) {
+                       Logger::error('No owner data found, the deletion message cannot be processed.', ['user' => $uid]);
+                       return false;
+               }
+
+               if (empty($owner['uprvkey'])) {
+                       Logger::error('No private key for owner found, the deletion message cannot be processed.', ['user' => $uid]);
+                       return false;
+               }
+
                $data = ['@context' => ActivityPub::CONTEXT,
                        'id' => System::baseUrl() . '/activity/' . System::createGUID(),
                        'type' => 'Delete',
index 1e4672887e04b46b1676f28cdd71f95c5b18c0c1..78f7c349a71eb855e2f05ebb3d8c528b4adcc83e 100644 (file)
@@ -26,7 +26,7 @@ class Crypto
        public static function rsaSign($data, $key, $alg = 'sha256')
        {
                if (empty($key)) {
-                       logger::warning('Empty key parameter', ['callstack' => System::callstack()]);
+                       Logger::warning('Empty key parameter', ['callstack' => System::callstack()]);
                }
                openssl_sign($data, $sig, $key, (($alg == 'sha1') ? OPENSSL_ALGO_SHA1 : $alg));
                return $sig;
@@ -42,7 +42,7 @@ class Crypto
        public static function rsaVerify($data, $sig, $key, $alg = 'sha256')
        {
                if (empty($key)) {
-                       logger::warning('Empty key parameter', ['callstack' => System::callstack()]);
+                       Logger::warning('Empty key parameter', ['callstack' => System::callstack()]);
                }
                return openssl_verify($data, $sig, $key, (($alg == 'sha1') ? OPENSSL_ALGO_SHA1 : $alg));
        }