summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2014-03-22 09:27:29 +0200
committerOran Agra <oran@redislabs.com>2014-03-22 09:27:29 +0200
commit4c827b4c48bb1162d8c5da4629d564b63557047e (patch)
tree86599178048779c424da4d35171a5de19092f461 /redis/client.py
parenta5dbfc1e3ff246dfd3188223e3e11c59da6f3e2d (diff)
downloadredis-py-4c827b4c48bb1162d8c5da4629d564b63557047e.tar.gz
add SSL support
Diffstat (limited to 'redis/client.py')
-rwxr-xr-x[-rw-r--r--]redis/client.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/redis/client.py b/redis/client.py
index 5285820..ae45e5c 100644..100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -18,6 +18,14 @@ from redis.exceptions import (
ExecAbortError,
)
+try:
+ import ssl
+ ssl_available = True
+ ssl_cert_reqs = ssl.CERT_NONE
+except ImportError:
+ ssl_available = False
+ ssl_cert_reqs = 0
+
SYM_EMPTY = b('')
@@ -345,8 +353,10 @@ class StrictRedis(object):
"""
url = urlparse(url)
- # We only support redis:// schemes.
- assert url.scheme == 'redis' or not url.scheme
+ # We only support redis:// and resiss:// schemes.
+ assert url.scheme == 'redis' or url.scheme == 'rediss' or not url.scheme
+ if url.scheme == 'rediss':
+ kwargs['use_ssl'] = True
# Extract the database ID from the path component if hasn't been given.
if db is None:
@@ -362,11 +372,18 @@ class StrictRedis(object):
db=0, password=None, socket_timeout=None,
connection_pool=None, charset='utf-8',
errors='strict', decode_responses=False,
- unix_socket_path=None):
+ unix_socket_path=None,
+ use_ssl=False, keyfile=None, certfile=None,
+ cert_reqs=ssl_cert_reqs, ca_certs=None):
if not connection_pool:
kwargs = {
'db': db,
'password': password,
+ 'keyfile': keyfile,
+ 'use_ssl': use_ssl,
+ 'certfile': certfile,
+ 'ca_certs': ca_certs,
+ 'cert_reqs': cert_reqs,
'socket_timeout': socket_timeout,
'encoding': charset,
'encoding_errors': errors,