Skip to content

Instantly share code, notes, and snippets.

@alcidesrivera
Last active August 29, 2015 14:24
Show Gist options
  • Save alcidesrivera/b2f59a81318c81bd5087 to your computer and use it in GitHub Desktop.
Save alcidesrivera/b2f59a81318c81bd5087 to your computer and use it in GitHub Desktop.
Xades
class Xades(object):
def apply_digital_signature(self, xml_document, file_pk12, password):
"""
Metodo que aplica la firma digital al XML
"""
JAR_PATH = 'firma/firmaXadesBes.jar'
JAVA_CMD = 'java'
ds_document = False
xml_str = etree.tostring(xml_document, encoding='utf8', method='xml')
# firma electrónica del xml
firma_path = os.path.join(os.path.dirname(__file__), JAR_PATH)
# invocación del jar de la firma electrónica
p = Popen([JAVA_CMD, '-jar', firma_path, xml_str, file_pk12, password], stdout=PIPE, stderr=STDOUT)
return p.communicate()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment