protocol: fail gracefully on cancellation

This commit is contained in:
Roman Zeyde 2016-03-12 20:42:14 +02:00
parent ea88f425f5
commit 1022e54d6a
3 changed files with 5 additions and 4 deletions

View File

@ -81,7 +81,7 @@ class Client(object):
except self.call_exception as e:
code, msg = e.args
log.warning('%s error #%s: %s', self.device_name, code, msg)
raise IOError(msg)
raise IOError(msg) # close current connection, keep server open
verifying_key = formats.decompress_pubkey(pubkey=result.public_key,
curve_name=self.curve)

View File

@ -139,7 +139,10 @@ class Handler(object):
log.debug('signing %d-byte blob', len(blob))
label = key['name'].decode('ascii') # label should be a string
signature = self.signer(label=label, blob=blob)
try:
signature = self.signer(label=label, blob=blob)
except IOError:
return _fail()
log.debug('signature: %s', binascii.hexlify(signature))
try:

View File

@ -55,8 +55,6 @@ def handle_connection(conn, handler):
msg = util.read_frame(conn)
reply = handler.handle(msg=msg)
util.send(conn, reply)
except IOError as e:
log.error('I/O error: %s', e)
except EOFError:
log.debug('goodbye agent')
except Exception as e: # pylint: disable=broad-except