From 0f33dbb2a7e006586815192cb65a2fa53c7a6be1 Mon Sep 17 00:00:00 2001 From: Martin van Es <martin@mrvanes.com> Date: Fri, 21 Jan 2022 10:13:06 +0100 Subject: [PATCH] Add HSM test script --- test_hsm.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 test_hsm.py diff --git a/test_hsm.py b/test_hsm.py new file mode 100755 index 0000000..ef66fcd --- /dev/null +++ b/test_hsm.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +from lxml import etree as ET +import xmlsec + +tree = ET.ElementTree(file='metadata/test/md0.xml') +root = tree.getroot() +ns = root.nsmap.copy() +ns['xml'] = 'http://www.w3.org/XML/1998/namespace' + +entity_descriptor = root.findall('md:EntityDescriptor', ns)[0] +signed = xmlsec.sign(entity_descriptor, key_spec="pkcs11:///usr/lib/softhsm/libsofthsm2.so/test?pin=secret") + +# print(ET.tostring(signed, pretty_print=True).decode()) + +if xmlsec.verify(signed, 'hsm.crt'): + print("Verified!") +else: + print("Fail") -- GitLab