Skip to content

Commit

Permalink
Combine ssl_verify with other SSL options
Browse files Browse the repository at this point in the history
  • Loading branch information
sfonteneau authored and miguelgrinberg committed Jan 5, 2024
1 parent c5f81cf commit cea2f92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/engineio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ def _connect_websocket(self, url, headers, engineio_path):
self.ssl_verify = False

if not self.ssl_verify:
extra_options['sslopt'] = {"cert_reqs": ssl.CERT_NONE}
if 'sslopt' in extra_options:
extra_options['sslopt'].update({"cert_reqs": ssl.CERT_NONE})
else:
extra_options['sslopt'] = {"cert_reqs": ssl.CERT_NONE}

# combine internally generated options with the ones supplied by the
# caller. The caller's options take precedence.
Expand Down
4 changes: 2 additions & 2 deletions tests/common/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ def test_websocket_connection_with_cert(self, create_connection):
http.auth = None
http.proxies = None
http.cert = 'foo.crt'
c = client.Client(http_session=http)
c = client.Client(http_session=http, ssl_verify=False)
c._read_loop_polling = mock.MagicMock()
c._read_loop_websocket = mock.MagicMock()
c._write_loop = mock.MagicMock()
Expand All @@ -889,7 +889,7 @@ def test_websocket_connection_with_cert(self, create_connection):

assert len(create_connection.call_args_list) == 1
assert create_connection.call_args[1] == {
'sslopt': {'certfile': 'foo.crt'},
'sslopt': {'cert_reqs': ssl.CERT_NONE, 'certfile': 'foo.crt'},
'header': {},
'cookie': '',
'enable_multithread': True,
Expand Down

0 comments on commit cea2f92

Please sign in to comment.