-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utility to allow extraction of embedded certificates in a form su…
…itable for later processing.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| extract_embedded.xsl | ||
| XSL stylesheet that takes a SAML 2.0 metadata file and extracts | ||
| all embedded certificates on entities in the form of a series of | ||
| PEM certificate blocks. | ||
| A descriptive comment is added to indicate the entity in question and | ||
| the KeyName used (if any) so that later processing can distinguish. | ||
| Author: Ian A. Young <ian@iay.org.uk> | ||
| --> | ||
| <xsl:stylesheet version="1.0" | ||
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
| xmlns:ds="http://www.w3.org/2000/09/xmldsig#" | ||
| xmlns:shibmeta="urn:mace:shibboleth:metadata:1.0" | ||
| xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns:wayf="http://sdss.ac.uk/2006/06/WAYF" | ||
| xmlns:str="http://exslt.org/strings" | ||
| exclude-result-prefixes="shibmeta md ds wayf str"> | ||
|
|
||
| <!-- Output is plain text --> | ||
| <xsl:output method="text"/> | ||
|
|
||
| <xsl:template match="//md:EntityDescriptor//md:KeyDescriptor[.//ds:X509Certificate]"> | ||
| <xsl:text>Entity: </xsl:text> | ||
| <xsl:value-of select="ancestor::md:EntityDescriptor/@entityID"/> | ||
| <xsl:text> KeyName: </xsl:text> | ||
| <xsl:choose> | ||
| <xsl:when test=".//ds:KeyName"> | ||
| <xsl:value-of select=".//ds:KeyName"/> | ||
| </xsl:when> | ||
| <xsl:otherwise> | ||
| <xsl:text>(none)</xsl:text> | ||
| </xsl:otherwise> | ||
| </xsl:choose> | ||
| <xsl:text>
</xsl:text> | ||
| <xsl:text>-----BEGIN CERTIFICATE-----
</xsl:text> | ||
| <xsl:apply-templates select="str:tokenize(.//ds:X509Certificate)"/> | ||
| <xsl:text>-----END CERTIFICATE-----
</xsl:text> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template match="token"> | ||
| <xsl:value-of select="."/> | ||
| <xsl:text>
</xsl:text> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template match="text()"> | ||
| <!-- do nothing --> | ||
| </xsl:template> | ||
| </xsl:stylesheet> |