I am trying to have an xml signed, where the signature is the last child element of the root. For this purpose Python’s signxml library is used. Previously the cryptography library was used to generate the key and certificate.
Upon running the default signxml configuration.
from lxml import etree
from signxml import XMLSigner, XMLVerifier
data_to_sign = "<Test/>"
cert = open("cert.pem").read()
key = open("privkey.pem").read()
root = etree.fromstring(data_to_sign)
signed_root = XMLSigner().sign(root, key=key, cert=cert)
verified_data = XMLVerifier().verify(signed_root).signed_xml
I get an error which says a child element is missing.
DocumentInvalid: Element '{http://www.w3.org/2000/09/xmldsig#}X509Data':
Missing child element(s). Expected is one of (
{http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial,
{http://www.w3.org/2000/09/xmldsig#}X509SKI,
{http://www.w3.org/2000/09/xmldsig#}X509SubjectName,
{http://www.w3.org/2000/09/xmldsig#}X509Certificate,
{http://www.w3.org/2000/09/xmldsig#}X509CRL,
##other{http://www.w3.org/2000/09/xmldsig#}* )., line 1
How to fix the error?
New contributor
Magemathician is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.