From b372fcbbb276d112aa74534d97273b4061429f39 Mon Sep 17 00:00:00 2001 From: Sheng Date: Wed, 12 Sep 2018 13:07:05 +0800 Subject: [PATCH] Pass None for empty password --- tests/test_handler.py | 2 ++ webssh/handler.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_handler.py b/tests/test_handler.py index 52acb3f..0ec42be 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -83,3 +83,5 @@ class TestIndexHandler(unittest.TestCase): with self.assertRaises(InvalidValueError) as exc: pkey = IndexHandler.get_pkey_obj('x'+key, password, fname) self.assertIn('Invalid private key', str(exc)) + with self.assertRaises(paramiko.PasswordRequiredException): + pkey = IndexHandler.get_pkey_obj(key, '', fname) diff --git a/webssh/handler.py b/webssh/handler.py index 63bc225..4637974 100644 --- a/webssh/handler.py +++ b/webssh/handler.py @@ -118,7 +118,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): @classmethod def get_pkey_obj(cls, privatekey, password, filename): - bpass = to_bytes(password) + bpass = to_bytes(password) if password else None pkey = cls.get_specific_pkey(paramiko.RSAKey, privatekey, bpass)\ or cls.get_specific_pkey(paramiko.DSSKey, privatekey, bpass)\