git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
namespace module is gone, plxrn provides PL-specific translations
[sfa.git]
/
sfa
/
trust
/
certificate.py
diff --git
a/sfa/trust/certificate.py
b/sfa/trust/certificate.py
index
98588a9
..
839d1df
100644
(file)
--- a/
sfa/trust/certificate.py
+++ b/
sfa/trust/certificate.py
@@
-46,7
+46,7
@@
import M2Crypto
from M2Crypto import X509
from sfa.util.sfalogging import sfa_logger
from M2Crypto import X509
from sfa.util.sfalogging import sfa_logger
-from sfa.util.
namespace
import urn_to_hrn
+from sfa.util.
xrn
import urn_to_hrn
from sfa.util.faults import *
def convert_public_key(key):
from sfa.util.faults import *
def convert_public_key(key):
@@
-312,11
+312,18
@@
class Certificate:
# load it (support for the ---parent--- tag as well as normal chained certs)
string = string.strip()
# 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
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 \
parts = []
if string.count('-----BEGIN CERTIFICATE-----') > 1 and \