diff --git a/lemur/certificates/service.py b/lemur/certificates/service.py index 9f249e39..2b8ec48e 100644 --- a/lemur/certificates/service.py +++ b/lemur/certificates/service.py @@ -401,6 +401,9 @@ def create_csr(**csr_config): encryption_algorithm=serialization.NoEncryption() ) + if isinstance(private_key, bytes): + private_key = private_key.decode('utf-8') + csr = request.public_bytes( encoding=serialization.Encoding.PEM ) diff --git a/lemur/tests/test_certificates.py b/lemur/tests/test_certificates.py index f38518c7..48827209 100644 --- a/lemur/tests/test_certificates.py +++ b/lemur/tests/test_certificates.py @@ -318,7 +318,6 @@ def test_extended_key_usage_schema(): def test_create_basic_csr(client): from cryptography import x509 from cryptography.hazmat.backends import default_backend - from cryptography.hazmat.primitives import serialization from lemur.certificates.service import create_csr csr_config = dict( common_name='example.com', @@ -332,7 +331,6 @@ def test_create_basic_csr(client): ) 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()) for name in csr.subject: assert name.value in csr_config.values()