Commit b372fcbb by Sheng

Pass None for empty password

parent 21d3f9bd
...@@ -83,3 +83,5 @@ class TestIndexHandler(unittest.TestCase): ...@@ -83,3 +83,5 @@ class TestIndexHandler(unittest.TestCase):
with self.assertRaises(InvalidValueError) as exc: with self.assertRaises(InvalidValueError) as exc:
pkey = IndexHandler.get_pkey_obj('x'+key, password, fname) pkey = IndexHandler.get_pkey_obj('x'+key, password, fname)
self.assertIn('Invalid private key', str(exc)) self.assertIn('Invalid private key', str(exc))
with self.assertRaises(paramiko.PasswordRequiredException):
pkey = IndexHandler.get_pkey_obj(key, '', fname)
...@@ -118,7 +118,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -118,7 +118,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
@classmethod @classmethod
def get_pkey_obj(cls, privatekey, password, filename): 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)\ pkey = cls.get_specific_pkey(paramiko.RSAKey, privatekey, bpass)\
or cls.get_specific_pkey(paramiko.DSSKey, privatekey, bpass)\ or cls.get_specific_pkey(paramiko.DSSKey, privatekey, bpass)\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment