Skip to content

Commit

Permalink
Corrige assinatura digital, melhora requirements removendo restricoes
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed May 11, 2023
1 parent 9dcd6f9 commit 46a68f6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq libffi-dev libxml2-dev libxslt1-dev libssl-dev
sudo apt-get install -qq libxml2-dev libxmlsec1-dev libxmlsec1-openssl
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
Expand Down
8 changes: 7 additions & 1 deletion pytrustnfe/nfe/assinatura.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from signxml import XMLSigner


class XMLSignerWithSHA1(XMLSigner):
def check_deprecated_methods(self):
pass


class Assinatura(object):
def __init__(self, arquivo, senha):
self.arquivo = arquivo
Expand All @@ -20,7 +25,7 @@ def assina_xml(self, xml_element, reference, getchildren=False):
if element.text is not None and not element.text.strip():
element.text = None

signer = XMLSigner(
signer = XMLSignerWithSHA1(
method=signxml.methods.enveloped,
signature_algorithm="rsa-sha1",
digest_algorithm="sha1",
Expand All @@ -30,6 +35,7 @@ def assina_xml(self, xml_element, reference, getchildren=False):
ns = {}
ns[None] = signer.namespaces["ds"]
signer.namespaces = ns
signer.excise_empty_xmlns_declarations = True

ref_uri = ("#%s" % reference) if reference else None
signed_root = signer.sign(
Expand Down
32 changes: 19 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
lxml >= 4.2.1, < 5
coveralls
Jinja2
# Sign xml dependencies
signxml==2.9.0 ; python_version < '3.7'
signxml ; python_version >= '3.7'
urllib3 >= 1.22
lxml >= 4.2.1
cryptography >= 3.4.8
pyOpenSSL >= 22.1.0
certifi >= 2018.1.18

# XmlSec
xmlsec >= 1.3.13

# pytrustnfe dependencies
Jinja2
pytz
zeep
reportlab
urllib3
suds-community
suds-requests4
defusedxml >= 0.7.1, < 1
eight >= 0.3.0, < 1
cryptography >= 2.1.4
pyOpenSSL == 22.1.0
certifi >= 2015.11.20.1
xmlsec >= 1.3.3
reportlab

# Test dependencies
coveralls
pytest>=4.1.1
pytest-cov
pytz
zeep

17 changes: 9 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages


VERSION = "1.0.62"
VERSION = "2.0.0"


setup(
Expand Down Expand Up @@ -50,13 +50,14 @@
long_description=open("README.md", "r").read(),
long_description_content_type="text/markdown",
install_requires=[
'urllib3 >= 1.22',
'xmlsec >= 1.3.3', # apt update;apt install libxmlsec1-dev pkg-config -y
'Jinja2 >= 2.8, <= 3.0.3',
'lxml >= 4.2.1, < 5',
'cryptography >= 2.1.4',
'pyOpenSSL == 22.1.0',
'suds',
'xmlsec >= 1.3.13', # apt update;apt install libxmlsec1-dev pkg-config -y
'lxml >= 4.2.1',
'cryptography >= 3.4.8',
'pyOpenSSL >= 17.5.0',
'certifi >= 2018.1.18',
'urllib3',
'Jinja2',
'suds-community',
'suds-requests4',
'reportlab',
'pytz',
Expand Down

0 comments on commit 46a68f6

Please sign in to comment.