Commit 18ea61fe authored by Mathieu Richardoz's avatar Mathieu Richardoz

Fix crash when establishing a secure connection

parent f18bbb43
......@@ -180,6 +180,13 @@ class BaseRedisCache(BaseCache):
socket_timeout=self.socket_timeout,
socket_connect_timeout=self.socket_connect_timeout,
)
# remove socket-related connection arguments
if kwargs.get('ssl', False):
del kwargs['socket_timeout']
del kwargs['socket_connect_timeout']
del kwargs['unix_socket_path']
client = redis.Redis(**kwargs)
kwargs.update(
parser_class=self.parser_class,
......
from redis.connection import UnixDomainSocketConnection, Connection
from redis.connection import UnixDomainSocketConnection, SSLConnection, Connection
class CacheConnectionPool(object):
......@@ -24,6 +24,7 @@ class CacheConnectionPool(object):
client,
host='127.0.0.1',
port=6379,
ssl=False,
db=1,
password=None,
parser_class=None,
......@@ -42,7 +43,9 @@ class CacheConnectionPool(object):
if pool is None:
connection_class = (
unix_socket_path and UnixDomainSocketConnection or Connection
unix_socket_path and UnixDomainSocketConnection
or ssl and SSLConnection
or Connection
)
kwargs = {
......
......@@ -6,8 +6,6 @@ from django.utils import six
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.six.moves.urllib.parse import parse_qs, urlparse
from redis.connection import SSLConnection
@python_2_unicode_compatible
class CacheKey(object):
......@@ -134,7 +132,7 @@ def parse_connection_kwargs(server, db=None, **kwargs):
pass
if url.scheme == 'rediss':
url_options['connection_class'] = SSLConnection
url_options['ssl'] = True
# last shot at the db value
url_options['db'] = int(url_options.get('db', db or 0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment