Using the Engine in a HTTPS Connection with a proxy.
Hi,
i'm trying to make a connection trough a HTTP proxy to an HTTPS endpoint with client certificate authentication, where the certificate is on a smartcard.
Therefore I loaded a dynamic engine with with a pkcs11 module. (Worked find, i can load the rsa private key and the x509 cert).
How to integrate the SSL Engine into a HTTP lib, to do requests?
So far, i tried to use the integrated httpslib:
def InitPKCS11Engine(id, enginePath, modulePath, pin):
try:
Engine.load_dynamic()
e = Engine.Engine('dynamic')
e.ctrl_cmd_string('SO_PATH', enginePath)
e.ctrl_cmd_string('ID', id)
e.ctrl_cmd_string('LIST_ADD', '1')
e.ctrl_cmd_string('LOAD', None)
e.ctrl_cmd_string("MODULE_PATH", modulePath)
e.ctrl_cmd_string("PIN", pin)
e.init()
e.set_default()
return e
except Exception as err:
print(err)
print(" Failed")
def getPKCS11PrivateKey(engine, pin):
return engine.load_private_key(CERT, pin)
def getPKCS11Cert(engine):
return engine.load_certificate(CERT)
if __name__ == '__main__':
e = InitPKCS11Engine('pkcs11', engine, MODULE_PATH, PIN)
con = httpslib.ProxyHTTPSConnection(PROXY, 8080)
con.putrequest("GET", TARGET)
con.endheaders()
con.connect()
res = con.getresponse()
print(res)
Currently it tries to connect to the proxy twice... and i don't get why. Is there a way to integrate the M2Crypto.SSL.SSLContext into the requests or urllib3 library ?
Thanks a lot in advance.
Cheers