SSH/Agent/Identity: replace user_error's with exceptions

This commit is contained in:
terrafrost 2015-08-31 23:36:56 -05:00
parent 724ba7ccc9
commit e399a320dc

View File

@ -134,6 +134,7 @@ class Identity
*
* @param String $message
* @return String
* @throws \RuntimeException on connection errors
* @access public
*/
function sign($message)
@ -142,13 +143,13 @@ class Identity
$packet = pack('CNa*Na*N', Agent::SSH_AGENTC_SIGN_REQUEST, strlen($this->key_blob), $this->key_blob, strlen($message), $message, 0);
$packet = pack('Na*', strlen($packet), $packet);
if (strlen($packet) != fputs($this->fsock, $packet)) {
user_error('Connection closed during signing');
throw new \RuntimeException('Connection closed during signing');
}
$length = current(unpack('N', fread($this->fsock, 4)));
$type = ord(fread($this->fsock, 1));
if ($type != Agent::SSH_AGENT_SIGN_RESPONSE) {
user_error('Unable to retreive signature');
throw new \RuntimeException('Unable to retreive signature');
}
$signature_blob = fread($this->fsock, $length - 1);