Skip to content

Commit 0b3310d

Browse files
committed
Metadata Parse error Exception handling
1 parent 6ca05dd commit 0b3310d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/saml2/mdstore.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import requests
1616
import six
1717

18+
from xml.etree.ElementTree import ParseError
1819
from saml2 import md
1920
from saml2 import saml
2021
from saml2 import samlp
@@ -612,8 +613,12 @@ def do_entity_descriptor(self, entity_descr):
612613
self.entity[entity_descr.entity_id] = _ent
613614

614615
def parse(self, xmlstr):
615-
self.entities_descr = md.entities_descriptor_from_string(xmlstr)
616-
616+
try:
617+
self.entities_descr = md.entities_descriptor_from_string(xmlstr)
618+
except Exception as e:
619+
logger.error(f'Metadata Parse Error on: {self.filename}')
620+
return
621+
617622
if not self.entities_descr:
618623
self.entity_descr = md.entity_descriptor_from_string(xmlstr)
619624
if self.entity_descr:

src/saml2/sigver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ def sign_statement(self, statement, node_name, key_file, node_id):
832832
'--privkey-pem', key_file,
833833
'--id-attr:ID', node_name,
834834
]
835-
835+
836836
if node_id:
837837
com_list.extend(['--node-id', node_id])
838838

@@ -952,7 +952,6 @@ def sign_statement(self, statement, node_name, key_file, node_id):
952952
"""
953953
import xmlsec
954954
import lxml.etree
955-
956955
xml = xmlsec.parse_xml(statement)
957956
signed = xmlsec.sign(xml, key_file)
958957
signed_str = lxml.etree.tostring(signed, xml_declaration=False, encoding="UTF-8")

0 commit comments

Comments
 (0)