From 9e90ad00bd7c6c09503f6900350d7ae27757ea10 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Feb 14 2017 20:09:22 +0000 Subject: Strip out textual representation of certificates on import Merges: #250 Signed-off-by: Patrick Uiterwijk Reviewed-by: Randy Barlow --- 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:]