Commit 667e2b5f authored by Jonathan Kamens's avatar Jonathan Kamens

Handle server_hostname and _context in SSLv2 SSLSocket

With the backport of SNI code from Python 3 to Python 2.7.x, Python's
ssl.py is now passing server_hostname and _context into SSLv2's
SSLSocket, rather than just SSLv3's SSLSocket, so we need to handle
those arguments.
parent 8264eebd
......@@ -62,6 +62,8 @@ class SSLSocket(socket):
ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True,
suppress_ragged_eofs=True,
server_hostname=None,
_context=None,
ciphers=None):
socket.__init__(self, _sock=sock)
......@@ -91,15 +93,18 @@ class SSLSocket(socket):
cert_reqs, ssl_version, ca_certs,
ciphers)
else:
self.context = __ssl__.SSLContext(ssl_version)
self.context.verify_mode = cert_reqs
if ca_certs:
self.context.load_verify_locations(ca_certs)
if certfile:
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)
if _context:
self.context = _context
else:
self.context = __ssl__.SSLContext(ssl_version)
self.context.verify_mode = cert_reqs
if ca_certs:
self.context.load_verify_locations(ca_certs)
if certfile:
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:
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