Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pynfe/processamento/assinatura.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ def assinar(self, xml: etree._Element, retorna_string=False) -> Union[str, etree

ref_uri = ("#%s" % reference) if reference else None
signed_root = signer.sign(xml, key=self.key, cert=self.cert, reference_uri=ref_uri)

# Reparse to ensure namespaces are correctly associated with elements
# This is required for lxml 6.x compatibility when using default namespace (None prefix)
signed_xml_str = etree.tostring(signed_root, encoding="unicode", pretty_print=False)
signed_root = etree.fromstring(signed_xml_str)

if retorna_string:
return etree.tostring(signed_root, encoding="unicode", pretty_print=False)
return signed_xml_str
else:
return signed_root
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ line-length = 100

[tool.poetry.dependencies]
requests = "^2.32.4"
signxml = "^4.1.0"
cryptography = "43.0.3"
lxml = "5.4.0"
signxml = ">=4.1.0"
cryptography = ">=43.0.3"
lxml = ">=5.4.0"
pyopenssl = "^25.1.0"

[tool.poetry.group.dev.dependencies]
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Dependencias basicas
requests
lxml
signxml
cryptography
requests>=2.32.4
lxml>=5.4.0
signxml>=4.1.0
cryptography>=43.0.3
# Opcional para NFS-e
#-r requirements-nfse.txt
# Opcional para Desenvolvimento (Pytest, Ruff, MyPy, etc)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_certificadoA1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# *-* encoding: utf8 *-*

import tempfile
import unittest

from pynfe.entidades.certificado import CertificadoA1
Expand All @@ -17,8 +18,9 @@ def test_assinatura_com_caminho(self):
self.a1 = CertificadoA1(self.certificado_correto)
cert = self.a1.separar_arquivo(senha=self.senha_correto, caminho=self.certificado_correto)

self.assertTrue(cert[0].startswith("/tmp/"))
self.assertTrue(cert[1].startswith("/tmp/"))
temp_dir = tempfile.gettempdir()
self.assertTrue(cert[0].startswith(temp_dir))
self.assertTrue(cert[1].startswith(temp_dir))

self.a1.excluir()

Expand Down
Loading