*
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/Zotlabs/Web/HTTPSig.php
*
+ * Other parts of the code for HTTP signing are taken from the Osada project.
+ * https://framagit.org/macgirvin/osada
+ *
* @see https://tools.ietf.org/html/draft-cavage-http-signatures-07
*/
return;
}
- $content = json_encode($data);
+ $content = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
// Header data that is about to be signed.
$host = parse_url($target, PHP_URL_HOST);
logger('Transmit to ' . $target . ' returned ' . $return_code);
}
- public static function verifyAP($content, $http_headers)
+ public static function getSigner($content, $http_headers)
{
$object = json_decode($content, true);
return false;
}
- if (!Crypto::rsaVerify($signed_data, $sig_block['signature'], $key, $algorithm)) {
+ if (!Crypto::rsaVerify($signed_data, $sig_block['signature'], $key['pubkey'], $algorithm)) {
return false;
}
}
}
- return true;
-
+ return $key['url'];
}
private static function fetchKey($id, $actor)
$profile = ActivityPub::fetchprofile($url);
if (!empty($profile)) {
- return $profile['pubkey'];
+ logger('Taking key from id ' . $id, LOGGER_DEBUG);
+ return ['url' => $url, 'pubkey' => $profile['pubkey']];
} elseif ($url != $actor) {
$profile = ActivityPub::fetchprofile($actor);
if (!empty($profile)) {
- return $profile['pubkey'];
+ logger('Taking key from actor ' . $actor, LOGGER_DEBUG);
+ return ['url' => $actor, 'pubkey' => $profile['pubkey']];
}
}