mirror of
https://github.com/friendica/friendica
synced 2025-04-30 09:44:22 +02:00
Fix headers (string to array) and make sure the signature doesn't change
This commit is contained in:
parent
f2dcc2788d
commit
befd5c860d
3 changed files with 14 additions and 16 deletions
|
@ -140,6 +140,9 @@ class HTTPSignature
|
|||
public static function createSig($head, $prvkey, $keyid = 'Key')
|
||||
{
|
||||
$return_headers = [];
|
||||
if (!empty($head)) {
|
||||
$return_headers = $head;
|
||||
}
|
||||
|
||||
$alg = 'sha512';
|
||||
$algorithm = 'rsa-sha512';
|
||||
|
@ -149,15 +152,7 @@ class HTTPSignature
|
|||
$headerval = 'keyId="' . $keyid . '",algorithm="' . $algorithm
|
||||
. '",headers="' . $x['headers'] . '",signature="' . $x['signature'] . '"';
|
||||
|
||||
$sighead = 'Authorization: Signature ' . $headerval;
|
||||
|
||||
if ($head) {
|
||||
foreach ($head as $k => $v) {
|
||||
$return_headers[] = $k . ': ' . $v;
|
||||
}
|
||||
}
|
||||
|
||||
$return_headers[] = $sighead;
|
||||
$return_headers['Authorization'] = ['Signature ' . $headerval];
|
||||
|
||||
return $return_headers;
|
||||
}
|
||||
|
@ -176,6 +171,9 @@ class HTTPSignature
|
|||
$fields = '';
|
||||
|
||||
foreach ($head as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$v = implode(', ', $v);
|
||||
}
|
||||
$headers .= strtolower($k) . ': ' . trim($v) . "\n";
|
||||
if ($fields) {
|
||||
$fields .= ' ';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue