diff options
author | peppelinux <giuseppe.demarco@unical.it> | 2021-03-06 17:00:38 +0100 |
---|---|---|
committer | peppelinux <giuseppe.demarco@unical.it> | 2021-03-06 17:02:27 +0100 |
commit | 0b3310d40c457531956a3032393f778ac566f72b (patch) | |
tree | ab3dd547728653c5e2f90c5f94584253984ee8a6 | |
parent | 6ca05dd8a95bf6bdb74dc742699f54febca23d05 (diff) | |
download | pysaml2-0b3310d40c457531956a3032393f778ac566f72b.tar.gz |
Metadata Parse error Exception handling
-rw-r--r-- | src/saml2/mdstore.py | 9 | ||||
-rw-r--r-- | src/saml2/sigver.py | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/saml2/mdstore.py b/src/saml2/mdstore.py index 96acfa1e..70bc1b41 100644 --- a/src/saml2/mdstore.py +++ b/src/saml2/mdstore.py @@ -15,6 +15,7 @@ from os.path import join import requests import six +from xml.etree.ElementTree import ParseError from saml2 import md from saml2 import saml from saml2 import samlp @@ -612,8 +613,12 @@ class InMemoryMetaData(MetaData): self.entity[entity_descr.entity_id] = _ent def parse(self, xmlstr): - self.entities_descr = md.entities_descriptor_from_string(xmlstr) - + try: + self.entities_descr = md.entities_descriptor_from_string(xmlstr) + except Exception as e: + logger.error(f'Metadata Parse Error on: {self.filename}') + return + if not self.entities_descr: self.entity_descr = md.entity_descriptor_from_string(xmlstr) if self.entity_descr: diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py index b950d18d..5bb9338c 100644 --- a/src/saml2/sigver.py +++ b/src/saml2/sigver.py @@ -832,7 +832,7 @@ class CryptoBackendXmlSec1(CryptoBackend): '--privkey-pem', key_file, '--id-attr:ID', node_name, ] - + if node_id: com_list.extend(['--node-id', node_id]) @@ -952,7 +952,6 @@ class CryptoBackendXMLSecurity(CryptoBackend): """ import xmlsec import lxml.etree - xml = xmlsec.parse_xml(statement) signed = xmlsec.sign(xml, key_file) signed_str = lxml.etree.tostring(signed, xml_declaration=False, encoding="UTF-8") |