Skip to content

Commit

Permalink
When _just_ using an SSL context we don't want breaking behavior (ela…
Browse files Browse the repository at this point in the history
…stic#673)

Also don't want to break backwards compat. So when chcking for depreicated values ignore
the check on verify_certs. Since it's True. the verify certs will be default true
in the ssl_context. And can be turned off in the SSL context when using it.
  • Loading branch information
fxdgear authored and honzakral committed Nov 28, 2017
1 parent 2a96ce1 commit 37490e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions elasticsearch/connection/http_urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
kw = {}

# if providing an SSL context, raise error if any other SSL related flag is used
if ssl_context and (verify_certs or ca_certs or ssl_version):
raise ImproperlyConfigured("When using `ssl_context`, `use_ssl`, `verify_certs`, `ca_certs` and `ssl_version` are not permitted")
if ssl_context and (ca_certs or ssl_version or use_ssl):
raise ImproperlyConfigured("When using `ssl_context`, `use_ssl`, `ca_certs` and `ssl_version` are not permitted")

# if ssl_context provided use SSL by default
if use_ssl or ssl_context:
Expand Down
1 change: 0 additions & 1 deletion test_elasticsearch/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_ssl_context_and_depreicated_values(self):
except AttributeError:
raise SkipTest("SSL Context not supported in this version of python")
self.assertRaises(ImproperlyConfigured, Urllib3HttpConnection, ssl_context=ctx, use_ssl=True)
self.assertRaises(ImproperlyConfigured, Urllib3HttpConnection, ssl_context=ctx, verify_certs=True)
self.assertRaises(ImproperlyConfigured, Urllib3HttpConnection, ssl_context=ctx, ca_certs="/some/path/to/cert.crt")
self.assertRaises(ImproperlyConfigured, Urllib3HttpConnection, ssl_context=ctx, ssl_version=ssl.PROTOCOL_SSLv23)

Expand Down

0 comments on commit 37490e2

Please sign in to comment.