# Path: pytrustnfe/certificado.py
# def extract_cert_and_key_from_pfx(pfx, password):
#     pfx = crypto.load_pkcs12(pfx, password)
#     # PEM formatted private key
#     key = crypto.dump_privatekey(crypto.FILETYPE_PEM, pfx.get_privatekey())
#     # PEM formatted certificate
#     cert = crypto.dump_certificate(crypto.FILETYPE_PEM, pfx.get_certificate())
#     return cert.decode(), key.decode()


import signxml
from lxml import etree
from pytrustnfe.certificado import extract_cert_and_key_from_pfx
from signxml import XMLSigner
# -*- coding: utf-8 -*-
# © 2016 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).



class Assinatura(object):
    def __init__(self, arquivo, senha):
        self.arquivo = arquivo
        self.senha = senha

    def assina_xml(self, xml_element, reference, getchildren=False):

# Path: pytrustnfe/certificado.py
# def extract_cert_and_key_from_pfx(pfx, password):
#     pfx = crypto.load_pkcs12(pfx, password)
#     # PEM formatted private key
#     key = crypto.dump_privatekey(crypto.FILETYPE_PEM, pfx.get_privatekey())
#     # PEM formatted certificate
#     cert = crypto.dump_certificate(crypto.FILETYPE_PEM, pfx.get_certificate())
#     return cert.decode(), key.decode()


# Path: pytrustnfe/nfe/assinatura.py
import signxml
from lxml import etree
from pytrustnfe.certificado import extract_cert_and_key_from_pfx
from signxml import XMLSigner

# -*- coding: utf-8 -*-
# © 2016 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).



class Assinatura(object):
    def __init__(self, arquivo, senha):
        self.arquivo = arquivo
        self.senha = senha

    def assina_xml(self, xml_element, reference, getchildren=False):

        cert, key = extract_cert_and_key_from_pfx(self.arquivo, self.senha)