Changeset View
Changeset View
Standalone View
Standalone View
src/conduit/ConduitClient.php
Context not available. | |||||
public function __construct($uri) { | public function __construct($uri) { | ||||
$this->uri = new PhutilURI($uri); | $this->uri = new PhutilURI($uri); | ||||
if (!strlen($this->uri->getDomain())) { | if (!@strlen($this->uri->getDomain())) { | ||||
throw new Exception( | throw new Exception( | ||||
pht("Conduit URI '%s' must include a valid host.", $uri)); | pht("Conduit URI '%s' must include a valid host.", $uri)); | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
$public_key = idx($meta, 'auth.key'); | $public_key = idx($meta, 'auth.key'); | ||||
if (!strlen($public_key)) { | if (!@strlen($public_key)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Unable to verify request signature, no "%s" present in '. | 'Unable to verify request signature, no "%s" present in '. | ||||
Context not available. | |||||
} | } | ||||
$signature = idx($meta, 'auth.signature'); | $signature = idx($meta, 'auth.signature'); | ||||
if (!strlen($signature)) { | if (!@strlen($signature)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Unable to verify request signature, no "%s" present '. | 'Unable to verify request signature, no "%s" present '. | ||||
Context not available. | |||||
} | } | ||||
$prefix = self::SIGNATURE_CONSIGN_1; | $prefix = self::SIGNATURE_CONSIGN_1; | ||||
if (strncmp($signature, $prefix, strlen($prefix)) !== 0) { | if (strncmp($signature, $prefix, @strlen($prefix)) !== 0) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Unable to verify request signature, signature format is not '. | 'Unable to verify request signature, signature format is not '. | ||||
'known.')); | 'known.')); | ||||
} | } | ||||
$signature = substr($signature, strlen($prefix)); | $signature = @substr($signature, @strlen($prefix)); | ||||
$input = self::encodeRequestDataForSignature( | $input = self::encodeRequestDataForSignature( | ||||
$method, | $method, | ||||
Context not available. | |||||
'Request signature verification failed: signature is not correct.')); | 'Request signature verification failed: signature is not correct.')); | ||||
} else { | } else { | ||||
// Some kind of error. | // Some kind of error. | ||||
if (strlen($err)) { | if (@strlen($err)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'OpenSSL encountered an error verifying the request signature: %s', | 'OpenSSL encountered an error verifying the request signature: %s', | ||||
Context not available. | |||||
} | } | ||||
} else if (is_string($data)) { | } else if (is_string($data)) { | ||||
$out[] = 'S'; | $out[] = 'S'; | ||||
$out[] = strlen($data); | $out[] = @strlen($data); | ||||
$out[] = ':'; | $out[] = ':'; | ||||
$out[] = $data; | $out[] = $data; | ||||
} else if (is_int($data)) { | } else if (is_int($data)) { | ||||
$out[] = 'I'; | $out[] = 'I'; | ||||
$out[] = strlen((string)$data); | $out[] = @strlen((string)$data); | ||||
$out[] = ':'; | $out[] = ':'; | ||||
$out[] = (string)$data; | $out[] = (string)$data; | ||||
} else if (is_null($data)) { | } else if (is_null($data)) { | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0