From a274a88e7e9ccd5c0e09b140c48a01854715f9f9 Mon Sep 17 00:00:00 2001 From: Sheng Date: Thu, 27 Jun 2019 13:40:58 +0800 Subject: [PATCH] Generate clear error message for invalid unencrypted key --- webssh/handler.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/webssh/handler.py b/webssh/handler.py index 8d9d287..d76e4e7 100644 --- a/webssh/handler.py +++ b/webssh/handler.py @@ -81,10 +81,11 @@ class PrivateKey(object): raise InvalidValueError('Need a password to decrypt the key.') except paramiko.SSHException as exc: logging.error(str(exc)) - raise InvalidValueError( - 'Invalid key or wrong password "{}" for decrypting it.' - .format(self.password) - ) + msg = 'Invalid key' + if self.password: + msg += ' or wrong password "{}" for decrypting it.'.format( + self.password) + raise InvalidValueError(msg) class MixinHandler(object):