Skip to content

Commit

Permalink
Fix faulty ssl sni intiation parameters (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhananjaysathe authored and thedrow committed Aug 4, 2019
1 parent b36bf88 commit ccbe683
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions amqp/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _wrap_context(self, sock, sslopts, check_hostname=None, **ctx_options):

def _wrap_socket_sni(self, sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=ssl.CERT_NONE,
ca_certs=None, do_handshake_on_connect=True,
ca_certs=None, do_handshake_on_connect=False,
suppress_ragged_eofs=True, server_hostname=None,
ciphers=None, ssl_version=None):
"""Socket wrap with SNI headers.
Expand Down Expand Up @@ -357,8 +357,10 @@ def _wrap_socket_sni(self, sock, keyfile=None, certfile=None,
hasattr(ssl, 'SSLContext')):
context = ssl.SSLContext(opts['ssl_version'])
context.verify_mode = cert_reqs
context.check_hostname = True
context.load_cert_chain(certfile, keyfile)
if cert_reqs != ssl.CERT_NONE:
context.check_hostname = True
if (certfile is not None) and (keyfile is not None):
context.load_cert_chain(certfile, keyfile)
sock = context.wrap_socket(sock, server_hostname=server_hostname)
return sock

Expand Down
2 changes: 1 addition & 1 deletion t/unit/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def test_wrap_socket_sni(self):
ca_certs=None, server_side=False,
ciphers=None, ssl_version=2,
suppress_ragged_eofs=True,
do_handshake_on_connect=True)
do_handshake_on_connect=False)

def test_shutdown_transport(self):
self.t.sock = None
Expand Down

0 comments on commit ccbe683

Please sign in to comment.