I have a code as below:
headers = {'content-type': 'ContentType.APPLICATION_XML'} uri = "www.client.url.com/hit-here/" clientCert = "path/to/cert/abc.crt" clientKey = "path/to/key/abc.key" PROTOCOL = ssl.PROTOCOL_TLSv1 context = ssl.SSLContext(PROTOCOL) context.load_default_certs() context.load_cert_chain(clientCert, clientKey) conn = httplib.HTTPSConnection(uri, some_port, context=context)
I am not a network programmer, so I did a few searches to establish a connection with a handshake and found ssl.SSLContext(PROTOCOL) as a necessary function, the code works fine.
Then I got to the checkpoint, my local one has version 2.7.10, but all production boxes have 2.7.3 with them, so SSLContext not supported, and updating the python version is not an / option in control.
I tried reading ssl - an SSL wrapper for socket objects , but could not understand.
what I tried (in vain):
s_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = ssl.wrap_socket(s_, keyfile=clientKey, certfile=clientCert, cert_reqs=ssl.CERT_REQUIRED) new_conn = s.connect((uri, some_port))
but returns:
SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)')
Question - how to create an SSL context in the old version in order to have a secure https connection?
NoobEditor
source share