Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Added support for SSL/TLS #116

Merged
merged 2 commits into from
Mar 28, 2016
Merged

Conversation

moserware
Copy link
Contributor

By design, Redis doesn't natively support encryption via SSL/TLS. However, it can be added with an SSL proxy.

For this reason, some popular Redis libraries support SSL connections.

This change adds support for SSL/TLS by leveraging asyncio's existing SSL support in asyncio.BaseEventLoop.create_connection and using its semantics.

I didn't exhaustively research or test this change, so this pull request is simply my first pass at how such a change might look. I welcome critical feedback on it.

Thanks for this library!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 92.389% when pulling 8dbbf99 on moserware:master into 9c8200a on aio-libs:master.

@asvetlov
Copy link
Contributor

Please fix pep8 errors and add tests

@popravich
Copy link
Contributor

Thanks for PR,
this looks good except few flake8 complaints.
I will take a closer look in a day or two.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 92.447% when pulling 21241f3 on moserware:master into 9c8200a on aio-libs:master.

@moserware
Copy link
Contributor Author

@asvetlov @popravich Thanks for the feedback! I fixed the PEP8 whitespace issues.

Regarding testing, I've only been using the ssl=True scenario (which uses defaults and works with a trusted certificate authority issued certificate)

It looks like when @oranagra of RedisLabs added SSL support to redis-py, he just noted that it worked with an SSL server.

One option is to create a self-signed certificate and then use stunnel locally. Perhaps with this setup, one could manually create the ssl.SSLContext and trust the generated certificate.

Any guidance on where I should go from here? I didn't know if you'd want to add something like stunnel to your testing environment.

Thanks again for your consideration of this PR!

P.S. Redislabs blog post when SSL was added to some popular clients.

@@ -36,13 +36,14 @@ class RedisPool:
"""Redis connections pool.
"""

def __init__(self, address, db=0, password=None, encoding=None,
def __init__(self, address, db=0, password=None, ssl=None, encoding=None,
Copy link
Contributor

Choose a reason for hiding this comment

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

The ssl parameter here must be keyword-only argument.

@popravich popravich merged commit 2155690 into aio-libs-abandoned:master Mar 28, 2016
@moserware
Copy link
Contributor Author

Thank you for cleaning this up and merging it! I look forward to using it via pip

@popravich
Copy link
Contributor

I will do release this week.

@moserware
Copy link
Contributor Author

👍 That'd be great. Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants