Python3 (#416)
* Fixing issue where decrypted credentials were not returning valid strings.
This commit is contained in:
parent
2d7a6ccf3c
commit
7e6278684c
|
@ -328,8 +328,8 @@ def test_create_certificate(issuer_plugin, authority, logged_in_admin):
|
||||||
def test_create_csr():
|
def test_create_csr():
|
||||||
from lemur.certificates.service import create_csr
|
from lemur.certificates.service import create_csr
|
||||||
|
|
||||||
csr, private_key = create_csr(common_name='ACommonName', organization='test', organizational_unit='Meters', country='US',
|
csr, private_key = create_csr(owner='joe@example.com', common_name='ACommonName', organization='test', organizational_unit='Meters', country='US',
|
||||||
state='CA', location='Here', owner='joe@example.com')
|
state='CA', location='Here')
|
||||||
assert csr
|
assert csr
|
||||||
assert private_key
|
assert private_key
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ class Vault(types.TypeDecorator):
|
||||||
|
|
||||||
# we only support strings and they should be of type bytes for Fernet
|
# we only support strings and they should be of type bytes for Fernet
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, six.string_types):
|
||||||
return None
|
return
|
||||||
|
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
value = bytes(value, 'utf8')
|
value = bytes(value, 'utf8')
|
||||||
|
@ -122,10 +122,12 @@ class Vault(types.TypeDecorator):
|
||||||
|
|
||||||
# if the value is not a string we aren't going to try to decrypt
|
# if the value is not a string we aren't going to try to decrypt
|
||||||
# it. this is for the case where the column is null
|
# it. this is for the case where the column is null
|
||||||
if not isinstance(value, six.string_types):
|
|
||||||
return None
|
|
||||||
|
|
||||||
# TODO this may raise an InvalidToken exception in certain
|
if not sys.version_info >= (3, 0):
|
||||||
# cases. Should we handle that?
|
if not isinstance(value, six.string_types):
|
||||||
# https://cryptography.io/en/latest/fernet/#cryptography.fernet.Fernet.decrypt
|
return
|
||||||
return MultiFernet(self.keys).decrypt(value)
|
return MultiFernet(self.keys).decrypt(value)
|
||||||
|
else:
|
||||||
|
if not value:
|
||||||
|
return
|
||||||
|
return str(MultiFernet(self.keys).decrypt(value), 'utf8')
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -52,7 +52,7 @@ install_requires = [
|
||||||
'marshmallow-sqlalchemy==0.8.0',
|
'marshmallow-sqlalchemy==0.8.0',
|
||||||
'marshmallow==2.4.0',
|
'marshmallow==2.4.0',
|
||||||
'pycrypto==2.6.1',
|
'pycrypto==2.6.1',
|
||||||
'cryptography==1.4',
|
'cryptography==1.5',
|
||||||
'pyopenssl==0.15.1',
|
'pyopenssl==0.15.1',
|
||||||
'pyjwt==1.4.0',
|
'pyjwt==1.4.0',
|
||||||
'xmltodict==0.9.2',
|
'xmltodict==0.9.2',
|
||||||
|
|
Loading…
Reference in New Issue