mirror of
https://github.com/friendica/friendica
synced 2025-05-01 21:04:23 +02:00
Enable communication with Peertube
This commit is contained in:
parent
2f427e9daa
commit
aa4aaf1971
3 changed files with 10 additions and 7 deletions
|
@ -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.
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue