Ensuring that private key is in string format before it gets stored (#504)

* Ensuring that private key is in string format before it gets stored

* Fixing failing test.
This commit is contained in:
kevgliss 2016-11-16 15:05:25 -08:00 committed by GitHub
parent 3f2691c5d4
commit 851d74da3d
2 changed files with 3 additions and 2 deletions

View File

@ -401,6 +401,9 @@ def create_csr(**csr_config):
encryption_algorithm=serialization.NoEncryption() encryption_algorithm=serialization.NoEncryption()
) )
if isinstance(private_key, bytes):
private_key = private_key.decode('utf-8')
csr = request.public_bytes( csr = request.public_bytes(
encoding=serialization.Encoding.PEM encoding=serialization.Encoding.PEM
) )

View File

@ -318,7 +318,6 @@ def test_extended_key_usage_schema():
def test_create_basic_csr(client): def test_create_basic_csr(client):
from cryptography import x509 from cryptography import x509
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from lemur.certificates.service import create_csr from lemur.certificates.service import create_csr
csr_config = dict( csr_config = dict(
common_name='example.com', common_name='example.com',
@ -332,7 +331,6 @@ def test_create_basic_csr(client):
) )
csr, pem = create_csr(**csr_config) csr, pem = create_csr(**csr_config)
private_key = serialization.load_pem_private_key(pem, password=None, backend=default_backend())
csr = x509.load_pem_x509_csr(csr, default_backend()) csr = x509.load_pem_x509_csr(csr, default_backend())
for name in csr.subject: for name in csr.subject:
assert name.value in csr_config.values() assert name.value in csr_config.values()