Skip to content

Instantly share code, notes, and snippets.

@mkowsiak
Forked from joostd/Makefile
Created March 1, 2019 11:31
Show Gist options
  • Save mkowsiak/d665602df3efb43d7e6d8e274a8cffe5 to your computer and use it in GitHub Desktop.
Save mkowsiak/d665602df3efb43d7e6d8e274a8cffe5 to your computer and use it in GitHub Desktop.
Use xmllint to validate SAML 2.0 metadata (or similarly, any other SAML document) using an XML Catalog file
all: saml-2.0-os xsd/xenc-schema.xsd xsd/xmldsig-core-schema.xsd xsd/xml.xsd xcatalog/saml-metadata.xml
saml-2.0-os:
mkdir -p saml-2.0-os
curl -O http://docs.oasis-open.org/security/saml/v2.0/saml-2.0-os.zip
unzip -d saml-2.0-os saml-2.0-os.zip *.xsd
xcatalog/saml-metadata.xml:
mkdir -p xcatalog
xmlcatalog --noout --create xcatalog/saml-metadata.xml
xmlcatalog --noout --add uri http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd ../xsd/xmldsig-core-schema.xsd xcatalog/saml-metadata.xml
xmlcatalog --noout --add uri http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd ../xsd/xenc-schema.xsd xcatalog/saml-metadata.xml
xmlcatalog --noout --add uri http://www.w3.org/2001/xml.xsd ../xsd/xml.xsd xcatalog/saml-metadata.xml
xsd/xenc-schema.xsd:
mkdir -p xsd
curl https://www.w3.org/TR/xmlenc-core/xenc-schema.xsd -o xsd/xenc-schema.xsd
xsd/xmldsig-core-schema.xsd:
mkdir -p xsd
curl https://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd -o xsd/xmldsig-core-schema.xsd
xsd/xml.xsd:
mkdir -p xsd
curl https://www.w3.org/2001/03/xml.xsd -o xsd/xml.xsd
clean:
-rm -rf xcatalog
-rm -rf xsd
-rm -rf saml-2.0-os
-rm saml-2.0-os.zip
#!/bin/sh
# validate SAML metadata according to XML schema
# eg
# curl -4s https://wayf.surfnet.nl/federate/metadata/saml20 | ./validate-metadata.sh -
#OPTIONS=--load-trace
OPTIONS=--noout
XML_CATALOG_FILES="./xcatalog/saml-metadata.xml" xmllint --schema saml-2.0-os/saml-schema-metadata-2.0.xsd $OPTIONS $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment