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

Attribute Error: 'NoneType' object has no attribute '_x509' #102

Closed
majurr opened this issue Mar 26, 2021 · 4 comments
Closed

Attribute Error: 'NoneType' object has no attribute '_x509' #102

majurr opened this issue Mar 26, 2021 · 4 comments

Comments

@majurr
Copy link

majurr commented Mar 26, 2021

Gente bom dia.
Ao tentar emitir NF-e ou fazer Download de XML recebo o erro abaixo

Traceback (most recent call last):
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in call
return await self.app(scope, receive, send)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/fastapi/applications.py", line 199, in call
await super().call(scope, receive, send)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/applications.py", line 111, in call
await self.middleware_stack(scope, receive, send)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc from None
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, _send)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in call
raise exc from None
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/routing.py", line 566, in call
await route.handle(scope, receive, send)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/routing.py", line 227, in handle
await self.app(scope, receive, send)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/routing.py", line 41, in app
response = await func(request)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/fastapi/routing.py", line 201, in app
raw_response = await run_endpoint_function(
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/fastapi/routing.py", line 150, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
File "/home/mario/.pyenv/versions/3.9.2/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "./main.py", line 38, in emitir_nfe
a1 = AssinaturaA1(certificado, senha)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/pynfe/processamento/assinatura.py", line 30, in init
self.key, self.cert = CertificadoA1(certificado).separar_arquivo(senha)
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/pynfe/entidades/certificado.py", line 67, in separar_arquivo
cert = crypto.dump_certificate(crypto.FILETYPE_PEM, pkcs12.get_certificate()).decode('utf-8')
File "/home/mario/.pyenv/versions/3.9.2/envs/dfe/lib/python3.9/site-packages/OpenSSL/crypto.py", line 1812, in dump_certificate
result_code = _lib.PEM_write_bio_X509(bio, cert._x509)
AttributeError: 'NoneType' object has no attribute '_x509'

Agradeço a atenção e ajuda de todos.

@leogregianin
Copy link
Collaborator

Bom dia @devjhunior,

Já fiz testes com a lib em python 3.6 e 3.7, acredito que com python 3.9 tenha pouco ou nenhum teste.

Acredito que o problema esteja nas versões das dependências no seu ambiente.

Pode informar quais as versões que tem instalado com os comandos abaixo?

python -c 'import OpenSSL; print(OpenSSL.__version__)'
python -c 'import cryptography; print(cryptography.__version__)'
python -c 'import requests; print(requests.__version__)'

@majurr
Copy link
Author

majurr commented Mar 29, 2021

Bom dia @devjhunior ,

Já fiz testes com a lib em python 3.6 e 3.7, acredito que com python 3.9 tenha pouco ou nenhum teste.

Acredito que o problema está nas versões das dependências no seu ambiente.

Pode informar quais são as versões que tem instalado com os comandos abaixo?

python -c 'import OpenSSL; print(OpenSSL.__version__)'
19.1.0
python -c 'import cryptography; print(cryptography.__version__)'
3.4.7
python -c 'import requests; print(requests.__version__)'
2.25.1

São as respectivas versões que estou trabalhando.
Obrigado pela resposta @leogregianin

@majurr
Copy link
Author

majurr commented Apr 6, 2021

[Resolvido]

Problema: Certificado digital corrompido - sem a chave privada.

@majurr majurr closed this as completed Apr 6, 2021
@SabrinaWinckler
Copy link

[Resolvido]

Problema: Certificado digital corrompido - sem a chave privada.

Como você pegou o certificado sem ficar corrompido?

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

3 participants