From: Josh Karlin Date: Thu, 7 Oct 2010 14:20:00 +0000 (-0400) Subject: Certificate can now read protogeni style pems which have some text at the top of... X-Git-Tag: sfa-1.0-4~8 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f3969ea0d8a2eb42ad47eaaa6685fe552c8f3d43;hp=71691622ac72ca684be69e971f6d58c6a2ccb8ee;p=sfa.git Certificate can now read protogeni style pems which have some text at the top of the file --- 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 \