No module named 'signxml'

Viewed 341

this is my code :

from lxml import etree

from signxml import XMLSigner, XMLVerifier

with open('keys/key', 'rb') as f:
    key = f.read()
with open('keys/certificate', 'rb') as f:
    cert = f.read()
data_to_sign = "<Test/>"
root = etree.fromstring(data_to_sign)
signed_root = XMLSigner().sign(root, key=key, cert=cert)
verified_data = XMLVerifier().verify(signed_root).signed_xml
print("the verified data is", verified_data)**

and I succefully installed the lxml with this command:

RUN apk add gcc python3-dev libxml2-dev libxslt-dev musl-dev openssl-dev libssl-dev libffi-dev libpq xmlsec
RUN echo "@edge http://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN echo "@edgecommunity http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add xmlsec@edge xmlsec-dev@edgecommunity
RUN pip install --upgrade pip
RUN pip install lxml==4.6.1 zeep==4.0.0 dm.xmlsec.binding xmlsec==1.3.9**

but I got this error :

 from signxml import XMLSigner, XMLVerifier
ModuleNotFoundError: No module named 'signxml'
1 Answers

finally I solved my problem by adding this command in my dockerfile :


RUN pip install lxml==4.6.1 zeep==4.0.0 dm.xmlsec.binding xmlsec==1.3.9 cryptography==2.9 signxml==2.7.2


Related