From f3969ea0d8a2eb42ad47eaaa6685fe552c8f3d43 Mon Sep 17 00:00:00 2001 From: Josh Karlin <jkarlin@bbn.com> Date: Thu, 7 Oct 2010 10:20:00 -0400 Subject: [PATCH] Certificate can now read protogeni style pems which have some text at the top of the file --- sfa/trust/certificate.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sfa/trust/certificate.py b/sfa/trust/certificate.py index 64ac865f..450f14df 100644 --- a/sfa/trust/certificate.py +++ b/sfa/trust/certificate.py @@ -299,11 +299,18 @@ class Certificate: # load it (support for the ---parent--- tag as well as normal chained certs) string = string.strip() - - - if not string.startswith('-----'): + + # If it's not in proper PEM format, wrap it + if string.count('-----BEGIN CERTIFICATE') == 0: string = '-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----' % string + # If there is a PEM cert in there, but there is some other text first + # such as the text of the certificate, skip the text + beg = string.find('-----BEGIN CERTIFICATE') + if beg > 0: + # skipping over non cert beginning + string = string[beg:] + parts = [] if string.count('-----BEGIN CERTIFICATE-----') > 1 and \ -- 2.47.0