From 148040630f36e388e42462bb95a5b894e9cb807d Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Feb 14 2017 09:05:15 +0000 Subject: [PATCH 1/2] Add textual certificate representation to generated certificates This helps test when an admin provides us certs like these, and also helps administrators when they go and check out the certificates we generated. Signed-off-by: Patrick Uiterwijk --- diff --git a/ipsilon/tools/certs.py b/ipsilon/tools/certs.py index b131ba9..e0ad41f 100644 --- a/ipsilon/tools/certs.py +++ b/ipsilon/tools/certs.py @@ -21,7 +21,7 @@ class Certificate(object): self.cert = os.path.join(self.path, '%s.pem' % prefix) self.subject = '/CN=%s' % subject command = ['openssl', - 'req', '-x509', '-batch', '-days', '1825', + 'req', '-x509', '-batch', '-days', '1825', '-text', '-newkey', 'rsa:2048', '-nodes', '-subj', self.subject, '-keyout', self.key, '-out', self.cert] proc = Popen(command) From 1612532de9c0cc37e84156f6bdb802f2e7ac8150 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Feb 14 2017 09:06:00 +0000 Subject: [PATCH 2/2] Strip out textual representation of certificates on import Signed-off-by: Patrick Uiterwijk --- diff --git a/ipsilon/tools/certs.py b/ipsilon/tools/certs.py index e0ad41f..9f2c42b 100644 --- a/ipsilon/tools/certs.py +++ b/ipsilon/tools/certs.py @@ -37,6 +37,12 @@ class Certificate(object): with open(self.cert, 'r') as f: cert = f.readlines() + # Find the beginning of the certificate + # This helps if the admin pointed us to a certificate that includes + # the OpenSSL textual representation (openssl x509 -text) + begin = cert.index('-----BEGIN CERTIFICATE-----\n') + cert = cert[begin:] + # poor man stripping of BEGIN/END lines if cert[0] == '-----BEGIN CERTIFICATE-----\n': cert = cert[1:]