Commit edd26a72 authored by Eugene Pankov's avatar Eugene Pankov

Merge pull request #1 from quantopian/ssl2_SSLSocket_arguments

Handle server_hostname and _context in SSLv2 SSLSocket
parents 8264eebd 667e2b5f
...@@ -62,6 +62,8 @@ class SSLSocket(socket): ...@@ -62,6 +62,8 @@ class SSLSocket(socket):
ssl_version=PROTOCOL_SSLv23, ca_certs=None, ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True, do_handshake_on_connect=True,
suppress_ragged_eofs=True, suppress_ragged_eofs=True,
server_hostname=None,
_context=None,
ciphers=None): ciphers=None):
socket.__init__(self, _sock=sock) socket.__init__(self, _sock=sock)
...@@ -91,15 +93,18 @@ class SSLSocket(socket): ...@@ -91,15 +93,18 @@ class SSLSocket(socket):
cert_reqs, ssl_version, ca_certs, cert_reqs, ssl_version, ca_certs,
ciphers) ciphers)
else: else:
self.context = __ssl__.SSLContext(ssl_version) if _context:
self.context.verify_mode = cert_reqs self.context = _context
if ca_certs: else:
self.context.load_verify_locations(ca_certs) self.context = __ssl__.SSLContext(ssl_version)
if certfile: self.context.verify_mode = cert_reqs
self.context.load_cert_chain(certfile, keyfile) if ca_certs:
if ciphers: self.context.load_verify_locations(ca_certs)
self.context.set_ciphers(ciphers) if certfile:
self._sslobj = self.context._wrap_socket(self._sock, server_side=server_side, ssl_sock=self) self.context.load_cert_chain(certfile, keyfile)
if ciphers:
self.context.set_ciphers(ciphers)
self._sslobj = self.context._wrap_socket(self._sock, server_side=server_side, ssl_sock=self, server_hostname=server_hostname)
if do_handshake_on_connect: if do_handshake_on_connect:
self.do_handshake() self.do_handshake()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment