From: Michael Date: Mon, 14 Jan 2019 12:10:11 +0000 (+0000) Subject: Enable communication with Peertube X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=aa4aaf1971c7aa83db529a83369b619123ae703c;p=friendica.git Enable communication with Peertube --- diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 47478c3cf7..04631aa2fb 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1156,7 +1156,7 @@ class Transmitter 'actor' => $owner['url'], 'object' => $profile['url'], 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], - 'to' => $profile['url']]; + 'to' => [$profile['url']]]; Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG); @@ -1184,7 +1184,7 @@ class Transmitter 'actor' => $profile['url'], 'object' => $owner['url']], 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], - 'to' => $profile['url']]; + 'to' => [$profile['url']]]; Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG); @@ -1212,7 +1212,7 @@ class Transmitter 'actor' => $profile['url'], 'object' => $owner['url']], 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], - 'to' => $profile['url']]; + 'to' => [$profile['url']]]; Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG); @@ -1247,7 +1247,7 @@ class Transmitter 'actor' => $owner['url'], 'object' => $profile['url']], 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], - 'to' => $profile['url']]; + 'to' => [$profile['url']]]; Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG); diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index 8545cd07c4..8eead1d2e5 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -18,6 +18,7 @@ class DateTimeFormat { const ATOM = 'Y-m-d\TH:i:s\Z'; const MYSQL = 'Y-m-d H:i:s'; + const HTTP = 'D, d M Y H:i:s \G\M\T'; /** * convert() shorthand for UTC. diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index 07ff5e805d..2b9e396241 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -12,6 +12,7 @@ use Friendica\Database\DBA; use Friendica\Model\User; use Friendica\Model\APContact; use Friendica\Protocol\ActivityPub; +use Friendica\Util\DateTimeFormat; /** * @brief Implements HTTP Signatures per draft-cavage-http-signatures-07. @@ -296,14 +297,15 @@ class HTTPSignature $path = parse_url($target, PHP_URL_PATH); $digest = 'SHA-256=' . base64_encode(hash('sha256', $content, true)); $content_length = strlen($content); + $date = DateTimeFormat::utcNow(DateTimeFormat::HTTP); - $headers = ['Content-Length: ' . $content_length, 'Digest: ' . $digest, 'Host: ' . $host]; + $headers = ['Date: ' . $date, 'Content-Length: ' . $content_length, 'Digest: ' . $digest, 'Host: ' . $host]; - $signed_data = "(request-target): post " . $path . "\ncontent-length: " . $content_length . "\ndigest: " . $digest . "\nhost: " . $host; + $signed_data = "(request-target): post " . $path . "\ndate: ". $date . "\ncontent-length: " . $content_length . "\ndigest: " . $digest . "\nhost: " . $host; $signature = base64_encode(Crypto::rsaSign($signed_data, $owner['uprvkey'], 'sha256')); - $headers[] = 'Signature: keyId="' . $owner['url'] . '#main-key' . '",algorithm="rsa-sha256",headers="(request-target) content-length digest host",signature="' . $signature . '"'; + $headers[] = 'Signature: keyId="' . $owner['url'] . '#main-key' . '",algorithm="rsa-sha256",headers="(request-target) date content-length digest host",signature="' . $signature . '"'; $headers[] = 'Content-Type: application/activity+json';