Commit 704d2b68 by Sheng

Check private key size for the final value

parent 8eb636d7
...@@ -90,16 +90,18 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -90,16 +90,18 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
def get_privatekey(self): def get_privatekey(self):
name = 'privatekey' name = 'privatekey'
lst = self.request.files.get(name) # multipart form lst = self.request.files.get(name) # multipart form
if not lst: if lst:
return self.get_argument(name, u'') # urlencoded form
else:
self.filename = lst[0]['filename'] self.filename = lst[0]['filename']
data = lst[0]['body'] data = lst[0]['body']
if len(data) > KEY_MAX_SIZE: value = self.decode_argument(data, name=name).strip()
raise InvalidValueError( else:
'Invalid private key: {}'.format(self.filename) value = self.get_argument(name, u'') # urlencoded form
)
return self.decode_argument(data, name=name) if len(value) > KEY_MAX_SIZE:
raise InvalidValueError(
'Invalid private key: {}'.format(self.filename)
)
return value
@classmethod @classmethod
def get_specific_pkey(cls, pkeycls, privatekey, password): def get_specific_pkey(cls, pkeycls, privatekey, password):
......
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