Actually i read a .pem file with M2Crypto RSA, all works fine but becase the virtual enviroment and the incompatibility of this on SSLv2_method on Ubuntu and Gunicorn i need to read and sign with the same methodology my code works fine with:
keys = RSA.load_key(archivo_pem)
cert_file = open(archivo_cer, 'r')
cert = base64.b64encode(cert_file.read())
xdoc = ET.fromstring(cfdi)
xsl_root = ET.parse('cadenaoriginal_3_3.xslt')
xsl = ET.XSLT(xsl_root)
cadena_original = xsl(xdoc)
digest = hashlib.new('sha256', str(cadena_original)).digest()
sello = base64.b64encode(keys.sign(digest, "sha256"))
comp = xdoc.get('Comprobante')
xdoc.attrib['Sello'] = sello
xdoc.attrib['Certificado'] = cert
return ET.tostring(xdoc)
I want change this
keys = RSA.load_key(archivo_pem)
keys.sign(digest, "sha256")
for a native method.
The key.pem beigns with
-----BEGIN PRIVATE KEY-----
MY KEY
-----END PRIVATE KEY-----
All works on console mode, but when we try to run it on Gunicorn with Venv and workers the M2Crypto version fail, and it doesn't matter what version we'll use with M2Crypto always will fail.
Any advice for a native mode?
Regards!
Try https://pypi.python.org/pypi/M2Crypto/0.26.0 … SSLv2 problems should be gone (as is the method).