1
0
Fork 0

Don't let the tests fail. The test user doesn't have a private key

This commit is contained in:
Michael 2020-08-07 17:05:49 +00:00
parent 7b13b7e9c8
commit ecd2d88b09

View file

@ -413,26 +413,28 @@ class HTTPSignature
*/ */
public static function fetchRaw($request, $uid = 0, $binary = false, $opts = []) public static function fetchRaw($request, $uid = 0, $binary = false, $opts = [])
{ {
$headers = [];
if (!empty($uid)) { if (!empty($uid)) {
$owner = User::getOwnerDataById($uid); $owner = User::getOwnerDataById($uid);
if (!$owner) { if (!$owner) {
return; return;
} }
// Header data that is about to be signed. if (!empty($owner['uprvkey'])) {
$host = parse_url($request, PHP_URL_HOST); // Header data that is about to be signed.
$path = parse_url($request, PHP_URL_PATH); $host = parse_url($request, PHP_URL_HOST);
$date = DateTimeFormat::utcNow(DateTimeFormat::HTTP); $path = parse_url($request, PHP_URL_PATH);
$date = DateTimeFormat::utcNow(DateTimeFormat::HTTP);
$headers = ['Date: ' . $date, 'Host: ' . $host]; $headers = ['Date: ' . $date, 'Host: ' . $host];
$signed_data = "(request-target): get " . $path . "\ndate: ". $date . "\nhost: " . $host; $signed_data = "(request-target): get " . $path . "\ndate: ". $date . "\nhost: " . $host;
$signature = base64_encode(Crypto::rsaSign($signed_data, $owner['uprvkey'], 'sha256')); $signature = base64_encode(Crypto::rsaSign($signed_data, $owner['uprvkey'], 'sha256'));
$headers[] = 'Signature: keyId="' . $owner['url'] . '#main-key' . '",algorithm="rsa-sha256",headers="(request-target) date host",signature="' . $signature . '"'; $headers[] = 'Signature: keyId="' . $owner['url'] . '#main-key' . '",algorithm="rsa-sha256",headers="(request-target) date host",signature="' . $signature . '"';
} else { }
$headers = [];
} }
if (!empty($opts['accept_content'])) { if (!empty($opts['accept_content'])) {