encrypt the httpsig for zot6 transport

This commit is contained in:
zotlabs
2018-02-07 21:53:47 -08:00
parent b21a5c3ce9
commit 6cf2e9945a
2 changed files with 24 additions and 4 deletions

View File

@@ -288,9 +288,11 @@ function zot_best_algorithm($methods) {
*
* @param string $url
* @param array $data
* @param array $channel (optional if using zot6 delivery)
* @param array $crypto (optional if encrypted httpsig, requires hubloc_sitekey and site_crypto elements)
* @return array see z_post_url() for returned data format
*/
function zot_zot($url, $data, $channel = null) {
function zot_zot($url, $data, $channel = null,$crypto = null) {
$headers = [];
@@ -298,7 +300,7 @@ function zot_zot($url, $data, $channel = null) {
$headers['X-Zot-Token'] = random_string();
$hash = \Zotlabs\Web\HTTPSig::generate_digest($data,false);
$headers['X-Zot-Digest'] = 'SHA-256=' . $hash;
$h = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'],'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,false,'sha512');
$h = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'],'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,false,'sha512',(($crypto) ? $crypto['hubloc_sitekey'] : ''), (($crypto) ? zot_best_algorithm($crypto['site_crypto']) : ''));
}
$redirects = 0;