Modificaciones menores a la plantilla XML para cancelación
This commit is contained in:
parent
9b09fbbcd1
commit
1df477e0b1
|
@ -30,6 +30,7 @@ class SATCertificate(object):
|
|||
def _init_values(self):
|
||||
self._rfc = ''
|
||||
self._serial_number = ''
|
||||
self._subject = ''
|
||||
self._not_before = None
|
||||
self._not_after = None
|
||||
self._is_fiel = False
|
||||
|
@ -67,6 +68,10 @@ class SATCertificate(object):
|
|||
def _get_data_cer(self, cer):
|
||||
self._cer = cer
|
||||
obj = x509.load_der_x509_certificate(cer, default_backend())
|
||||
|
||||
# ~ print(1, obj.issuer.rfc4514_string())
|
||||
self._subject = obj.subject.rfc4514_string()
|
||||
|
||||
self._rfc = obj.subject.get_attributes_for_oid(
|
||||
NameOID.X500_UNIQUE_IDENTIFIER)[0].value.split(' ')[0]
|
||||
self._serial_number = '{0:x}'.format(obj.serial_number)[1::2]
|
||||
|
@ -152,11 +157,16 @@ class SATCertificate(object):
|
|||
node = xmlsec.tree.find_node(tree, 'X509Certificate')
|
||||
node.text = self.cer_txt
|
||||
|
||||
# ~ node = xmlsec.tree.find_node(tree, 'SignatureValue')
|
||||
# ~ node.text = node.text.replace('\n', '')
|
||||
node = xmlsec.tree.find_node(tree, 'X509IssuerName')
|
||||
node.text = self.subject
|
||||
node = xmlsec.tree.find_node(tree, 'X509SerialNumber')
|
||||
node.text = self.serial_number
|
||||
|
||||
# ~ node = xmlsec.tree.find_node(tree, 'Modulus')
|
||||
# ~ node.text = node.text.replace('\n', '')
|
||||
node = xmlsec.tree.find_node(tree, 'SignatureValue')
|
||||
node.text = node.text.replace('\n', '')
|
||||
|
||||
node = xmlsec.tree.find_node(tree, 'Modulus')
|
||||
node.text = node.text.replace('\n', '')
|
||||
|
||||
return tree
|
||||
|
||||
|
@ -168,6 +178,10 @@ class SATCertificate(object):
|
|||
def serial_number(self):
|
||||
return self._serial_number
|
||||
|
||||
@property
|
||||
def subject(self):
|
||||
return self._subject
|
||||
|
||||
@property
|
||||
def not_before(self):
|
||||
return self._not_before
|
||||
|
|
|
@ -250,6 +250,34 @@ DEFAULT_GLOBAL = {
|
|||
'clave_sat': '01010101',
|
||||
}
|
||||
|
||||
# ~ TEMPLATE_CANCEL = """<Cancelacion RfcEmisor="{rfc}" Fecha="{fecha}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://cancelacfd.sat.gob.mx">
|
||||
# ~ <Folios>
|
||||
# ~ <UUID>{uuid}</UUID>
|
||||
# ~ </Folios>
|
||||
# ~ <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
||||
# ~ <SignedInfo>
|
||||
# ~ <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
|
||||
# ~ <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
|
||||
# ~ <Reference URI="">
|
||||
# ~ <Transforms>
|
||||
# ~ <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
|
||||
# ~ </Transforms>
|
||||
# ~ <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
|
||||
# ~ <DigestValue />
|
||||
# ~ </Reference>
|
||||
# ~ </SignedInfo>
|
||||
# ~ <SignatureValue />
|
||||
# ~ <KeyInfo>
|
||||
# ~ <X509Data>
|
||||
# ~ <X509SubjectName />
|
||||
# ~ <X509IssuerSerial />
|
||||
# ~ <X509Certificate />
|
||||
# ~ </X509Data>
|
||||
# ~ <KeyValue />
|
||||
# ~ </KeyInfo>
|
||||
# ~ </Signature>
|
||||
# ~ </Cancelacion>
|
||||
# ~ """
|
||||
TEMPLATE_CANCEL = """<Cancelacion RfcEmisor="{rfc}" Fecha="{fecha}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://cancelacfd.sat.gob.mx">
|
||||
<Folios>
|
||||
<UUID>{uuid}</UUID>
|
||||
|
@ -268,12 +296,14 @@ TEMPLATE_CANCEL = """<Cancelacion RfcEmisor="{rfc}" Fecha="{fecha}" xmlns:xsi="h
|
|||
</SignedInfo>
|
||||
<SignatureValue />
|
||||
<KeyInfo>
|
||||
<X509Data>
|
||||
<X509SubjectName />
|
||||
<X509IssuerSerial />
|
||||
<X509Certificate />
|
||||
</X509Data>
|
||||
<KeyValue />
|
||||
<X509Data>
|
||||
<X509IssuerSerial>
|
||||
<X509IssuerName />
|
||||
<X509SerialNumber />
|
||||
</X509IssuerSerial>
|
||||
<X509Certificate />
|
||||
</X509Data>
|
||||
<KeyValue />
|
||||
</KeyInfo>
|
||||
</Signature>
|
||||
</Cancelacion>
|
||||
|
|
Loading…
Reference in New Issue