Skip to content

Commit

Permalink
metadata_tostring_fix handle and return only strings
Browse files Browse the repository at this point in the history
  • Loading branch information
peppelinux committed Dec 15, 2020
1 parent ca0696c commit b6a5322
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/saml2/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@
def metadata_tostring_fix(desc, nspair, xmlstring=""):
if not xmlstring:
xmlstring = desc.to_string(nspair)

try:
if "\"xs:string\"" in xmlstring and XMLNSXS not in xmlstring:
xmlstring = xmlstring.replace(MDNS, MDNS + XMLNSXS)
except TypeError:
if b"\"xs:string\"" in xmlstring and bXMLNSXS not in xmlstring:
xmlstring = xmlstring.replace(bMDNS, bMDNS + bXMLNSXS)

return xmlstring


Expand Down
15 changes: 12 additions & 3 deletions tools/make_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
help="xmlsec binaries to be used for the signing")
parser.add_argument('-w', dest='wellknown',
help="Use wellknown namespace prefixes")
parser.add_argument('-S', dest='signalg',
default='http://www.w3.org/2000/09/xmldsig#rsa-sha1',
help="Algorithm to sign the metadata")
parser.add_argument('-D', dest='digestalg',
default='http://www.w3.org/2000/09/xmldsig#sha1',
help="Algorithm to compute the digest of the metadata")
parser.add_argument(dest="config", nargs="+")
args = parser.parse_args()

Expand Down Expand Up @@ -70,16 +76,19 @@
args.sign, secc)
valid_instance(desc)
xmldoc = metadata_tostring_fix(desc, nspair, xmldoc)
print(xmldoc.decode("utf-8"))
print(xmldoc)
else:
for eid in eds:
if args.sign:
assert conf.key_file
assert conf.cert_file
eid, xmldoc = sign_entity_descriptor(eid, args.id, secc)
sign_alg = args.signalg
digest_alg = args.digestalg
eid, xmldoc = sign_entity_descriptor(eid, args.id, secc, sign_alg,
digest_alg)
else:
xmldoc = None

valid_instance(eid)
xmldoc = metadata_tostring_fix(eid, nspair, xmldoc)
print(xmldoc.decode("utf-8"))
print(xmldoc)

0 comments on commit b6a5322

Please sign in to comment.