Last active
June 8, 2018 14:39
-
-
Save markcallen/6e027b694a6fe0a3a01413b68616fdc9 to your computer and use it in GitHub Desktop.
Get the encryption certificate from an ADFS metadata file
This file contains hidden or 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
| import sys | |
| from xml.etree import cElementTree as ET | |
| x509s = [] | |
| def read_in(): | |
| return ET.fromstring(sys.stdin.read()) | |
| def main(): | |
| xml = read_in() | |
| for e in xml.findall(".//*[@use='signing']"): | |
| for x509 in e.iter("{http://www.w3.org/2000/09/xmldsig#}X509Certificate"): | |
| x509s.append(x509.text) | |
| for x in range(1, len(x509s)): | |
| if x509s[x] != x509s[x-1]: | |
| raise ValueError("x509 encryption certificates are not the same") | |
| print x509s[0] | |
| if __name__ == '__main__': | |
| main() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Takes the xml file from standard in