Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X509SerialNumber schema validation fails with large serial number size #8

Open
bit4bit opened this issue Oct 18, 2020 · 3 comments
Open

Comments

@bit4bit
Copy link

bit4bit commented Oct 18, 2020

hi, for larger serial numbers throws

lxml.etree.DocumentInvalid: Element '{http://www.w3.org/2000/09/xmldsig#}X509SerialNumber': '34255301462796514282327995225552892834' is not a valid value of the atomic type 'xs:integer'.
@etobella
Copy link
Owner

Can you give the traceback in order to check whenbthe error is raised?

@bit4bit
Copy link
Author

bit4bit commented Oct 22, 2020

hi

Traceback (most recent call last):
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/bin/facho", line 11, in <module>
    load_entry_point('facho', 'console_scripts', 'facho')()
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/bit4bit/progs/ETRIVIAL/facho/facho/cli.py", line 233, in sign_xml
    f.write(signer.sign_xml_string(document))
  File "/home/bit4bit/progs/ETRIVIAL/facho/facho/fe/fe.py", line 213, in sign_xml_string
    signature = self.sign_xml_element(xml)
  File "/home/bit4bit/progs/ETRIVIAL/facho/facho/fe/fe.py", line 275, in sign_xml_element
    ctx.verify(signature)
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/lib/python3.8/site-packages/xades-0.2.1-py3.8.egg/xades/xades_context.py", line 91, in verify
    res = super(XAdESContext, self).verify(node)
  File "/home/bit4bit/progs/ETRIVIAL/facho-venv/lib/python3.8/site-packages/xmlsig/signature_context.py", line 156, in verify
    schema.assertValid(node)
  File "src/lxml/etree.pyx", line 3623, in lxml.etree._Validator.assertValid
lxml.etree.DocumentInvalid: Element '{http://www.w3.org/2000/09/xmldsig#}X509SerialNumber': '34255301462796514282327995225552892834' is not a valid value of the atomic type 'xs:integer'.
rake aborted!

we fix removing :

serial = xmlsig.template.x509_data_add_issuer_serial(data)
xmlsig.template.x509_issuer_serial_add_serial_number(serial)

see at https://git.disroot.org/Etrivial/facho/commit/22716cf5c5b1ce9e3a2a36ccb0c105f74483f2b0
thanks

@etobella
Copy link
Owner

After checking, the problem is that your serial number is bigger than expected, the problem is related to libxml2, as you can check on https://mail.gnome.org/archives/xml/2008-March/msg00051.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants