Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use use ssl_context or don't but don't mix #714

Merged
merged 4 commits into from Mar 4, 2018

Conversation

fxdgear
Copy link
Contributor

@fxdgear fxdgear commented Jan 18, 2018

No description provided.

if not ssl_context:
# if no SSLContext we must make one

if not ca_certs and verify_certs:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ca_certs will only be Empty is certifi is not installed. Might be better if passed into the create_ssl_context function.

raise ImproperlyConfigured("Root certificates are missing for certificate "
"validation. Either pass them in using the ca_certs parameter or "
"install certifi to use it automatically.")
if ssl_version:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ssl_verison is passed in, we need to make sure this gets applied to the SSLContext object. Fixing coming soon.

@@ -116,9 +125,6 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
'assert_hostname': ssl_assert_hostname,
'assert_fingerprint': ssl_assert_fingerprint,
'ssl_context': ssl_context,
'cert_file': client_cert,
'ca_certs': ca_certs,
'key_file': client_key,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by leaving these here in the previous version of the SSLContext iterations, we're "half-assing" the ssl context implemetation. And as such it's causing issues. Since we are creating the SSLContext for the user if they don't pass it in, we shouldn't need to worry about passing through these variables anyway. So i'm removing them

@@ -105,7 +114,7 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
except AttributeError:
ssl_context = None

if not verify_certs and ssl_context is not None:
if not verify_certs:
ssl_context.check_hostname = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fail if ssl_context is None. Please add tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ssl_context should never be None, if it is we need to fail loud.

I’ll raise an exception in that case.

@fxdgear fxdgear changed the title simplify logic, remove passing through of depreciated parameters [wip] Use use ssl_context or don't but don't mix Jan 23, 2018
@fxdgear fxdgear added the WIP label Jan 23, 2018
@@ -80,7 +80,9 @@ 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 (ca_certs or ssl_version):
if ssl_context and ( use_ssl or verify_certs or ca_certs or client_cert or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify_certs defaults to True

Not going to deprecate and replace with SSLContext.
But instead give option for using SSLContext next to the original way of
handling SSL.
@fxdgear fxdgear changed the title [wip] Use use ssl_context or don't but don't mix Use use ssl_context or don't but don't mix Mar 1, 2018
@fxdgear fxdgear removed the WIP label Mar 1, 2018
@fxdgear fxdgear merged commit 058d38f into elastic:master Mar 4, 2018
fbacchella pushed a commit to fbacchella/elasticsearch-py that referenced this pull request Mar 9, 2018
* Use original SSL process and add SSLContext

Not going to deprecate and replace with SSLContext.
But instead give option for using SSLContext next to the original way of
handling SSL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants