X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Ftrust%2Fcertificate.py;h=25bb99a753194b1fac69f4a775a45c873b4dd267;hb=99e9f96209b9ebfd1853e7b8902a1a0fe893eaa2;hp=98588a976d49a38cb3836faa28754ac8cbff8273;hpb=dbce495b6f2e7d8dccbfb18c5507907d784c143b;p=sfa.git diff --git a/sfa/trust/certificate.py b/sfa/trust/certificate.py index 98588a97..25bb99a7 100644 --- a/sfa/trust/certificate.py +++ b/sfa/trust/certificate.py @@ -312,11 +312,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 \