Merge remote-tracking branch 'mike/master' into dev

This commit is contained in:
Mario Vavti 2018-01-14 07:42:58 +01:00
commit 8970d30c93
3 changed files with 9 additions and 4 deletions

View File

@ -38,14 +38,19 @@ class Owa extends \Zotlabs\Web\Controller {
foreach($r as $hubloc) { foreach($r as $hubloc) {
$verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']); $verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']);
if($verified && $verified['header_signed'] && $verified['header_valid']) { if($verified && $verified['header_signed'] && $verified['header_valid']) {
logger('OWA header: ' . print_r($verified,true),LOGGER_DATA);
logger('OWA success: ' . $hubloc['hubloc_addr'],LOGGER_DATA);
$ret['success'] = true; $ret['success'] = true;
$token = random_string(32); $token = random_string(32);
\Zotlabs\Zot\Verify::create('owt',0,$token,$r[0]['hubloc_addr']); \Zotlabs\Zot\Verify::create('owt',0,$token,$hubloc['hubloc_addr']);
$result = ''; $result = '';
openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']); openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']);
$ret['encrypted_token'] = base64url_encode($result); $ret['encrypted_token'] = base64url_encode($result);
break; break;
} }
else {
logger('OWA fail: ' . $hubloc['hubloc_id'] . ' ' . $hubloc['hubloc_addr']);
}
} }
} }
} }

View File

@ -117,7 +117,7 @@ class HTTPSig {
logger('verified: ' . $x, LOGGER_DEBUG); logger('verified: ' . $x, LOGGER_DEBUG);
if($x === false) if(! $x)
return $result; return $result;
if(! $spoofable) if(! $spoofable)

View File

@ -22,13 +22,13 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') {
$alg = OPENSSL_ALGO_SHA256; $alg = OPENSSL_ALGO_SHA256;
$verify = @openssl_verify($data,$sig,$key,$alg); $verify = @openssl_verify($data,$sig,$key,$alg);
if(! $verify) { if($verify === (-1)) {
while($msg = openssl_error_string()) while($msg = openssl_error_string())
logger('openssl_verify: ' . $msg,LOGGER_NORMAL,LOG_ERR); logger('openssl_verify: ' . $msg,LOGGER_NORMAL,LOG_ERR);
btlogger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR); btlogger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR);
} }
return $verify; return (($verify > 0) ? true : false);
} }
function pkcs5_pad ($text, $blocksize) function pkcs5_pad ($text, $blocksize)