From 72a390c5635d1f9df43f75db3b633e180d8dab32 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Sun, 9 Oct 2016 00:06:15 -0700 Subject: [PATCH] Ensure the openssl and cryptography work under python3. (#438) --- lemur/certificates/views.py | 2 +- lemur/plugins/lemur_cryptography/plugin.py | 6 +++--- lemur/plugins/lemur_openssl/plugin.py | 5 ++++- lemur/static/app/angular/domains/view/view.tpl.html | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lemur/certificates/views.py b/lemur/certificates/views.py index d41a239a..37363b0c 100644 --- a/lemur/certificates/views.py +++ b/lemur/certificates/views.py @@ -887,7 +887,7 @@ class CertificateExport(AuthenticatedResource): extension, passphrase, data = plugin.export(cert.body, cert.chain, cert.private_key, options) # we take a hit in message size when b64 encoding - return dict(extension=extension, passphrase=passphrase, data=base64.b64encode(data)) + return dict(extension=extension, passphrase=passphrase, data=base64.b64encode(data).decode('utf-8')) api.add_resource(CertificatesList, '/certificates', endpoint='certificates') diff --git a/lemur/plugins/lemur_cryptography/plugin.py b/lemur/plugins/lemur_cryptography/plugin.py index 1c8681c3..e3058424 100644 --- a/lemur/plugins/lemur_cryptography/plugin.py +++ b/lemur/plugins/lemur_cryptography/plugin.py @@ -51,7 +51,7 @@ def build_root_certificate(options): cert_pem = cert.public_bytes( encoding=serialization.Encoding.PEM - ) + ).decode('utf-8') private_key_pem = private_key.private_bytes( encoding=serialization.Encoding.PEM, @@ -82,7 +82,7 @@ def issue_certificate(csr, options): builder = builder.serial_number(int(uuid.uuid4())) private_key = serialization.load_pem_private_key( - options['authority'].authority_certificate.private_key, + bytes(options['authority'].authority_certificate.private_key, 'utf-8'), password=None, backend=default_backend() ) @@ -91,7 +91,7 @@ def issue_certificate(csr, options): return cert.public_bytes( encoding=serialization.Encoding.PEM - ) + ).decode('utf-8') class CryptographyIssuerPlugin(IssuerPlugin): diff --git a/lemur/plugins/lemur_openssl/plugin.py b/lemur/plugins/lemur_openssl/plugin.py index 2bf22087..366b3361 100644 --- a/lemur/plugins/lemur_openssl/plugin.py +++ b/lemur/plugins/lemur_openssl/plugin.py @@ -60,7 +60,10 @@ def create_pkcs12(cert, chain, p12_tmp, key, alias, passphrase): # Create PKCS12 keystore from private key and public certificate with mktempfile() as cert_tmp: with open(cert_tmp, 'w') as f: - f.writelines([cert.strip() + "\n", chain.strip() + "\n"]) + if chain: + f.writelines([cert.strip() + "\n", chain.strip() + "\n"]) + else: + f.writelines([cert.strip() + "\n"]) run_process([ "openssl", diff --git a/lemur/static/app/angular/domains/view/view.tpl.html b/lemur/static/app/angular/domains/view/view.tpl.html index d202ffbd..664b4c38 100644 --- a/lemur/static/app/angular/domains/view/view.tpl.html +++ b/lemur/static/app/angular/domains/view/view.tpl.html @@ -1,7 +1,7 @@

Domains - Zone transfers as scary

+ Zone transfers are scary