From 6c91b03cc6661904f74c9b218106e0020dd208b7 Mon Sep 17 00:00:00 2001 From: David Klaftenegger Date: Thu, 7 Apr 2016 02:25:53 +0200 Subject: [PATCH] Minor code improvements --- acertmgr_ssl.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/acertmgr_ssl.py b/acertmgr_ssl.py index 8991632..2b4d1cc 100644 --- a/acertmgr_ssl.py +++ b/acertmgr_ssl.py @@ -26,7 +26,7 @@ except ImportError: # @param cert_file the path to the certificate # @return the tuple of dates: (notBefore, notAfter) def cert_valid_times(cert_file): - with open(cert_file) as f: + with open(cert_file, 'r') as f: cert_data = f.read() cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_data) asn1time = str('%Y%m%d%H%M%SZ'.encode('utf8')) @@ -46,7 +46,6 @@ def cert_request(names, key): req.add_extensions(extensions) req.set_pubkey(key) req.sign(key, 'sha256') - #return crypto.dump_certificate_request(crypto.FILETYPE_PEM, req) return req # @brief convert certificate to PEM format @@ -59,7 +58,7 @@ def cert_to_pem(cert): # @param path path to key file # @return the key in pyopenssl format def read_key(path): - with open(path) as f: + with open(path, 'r') as f: key_data = f.read() return crypto.load_privatekey(crypto.FILETYPE_PEM, key_data)