Skip to content

Commit 17ff377

Browse files
committed
construct SSL connections from URLs. #446
1 parent de7d284 commit 17ff377

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

redis/connection.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,14 @@ def from_url(cls, url, db=None, **kwargs):
635635
For example::
636636
637637
redis://[:password]@localhost:6379/0
638+
rediss://[:password]@localhost:6379/0
638639
unix://[:password]@/path/to/socket.sock?db=0
639640
641+
Three URL schemes are supported:
642+
redis:// creates a normal TCP socket connection
643+
rediss:// creates a SSL wrapped TCP socket connection
644+
unix:// creates a Unix Domain Socket connection
645+
640646
There are several ways to specify a database number. The parse function
641647
will return the first specified option:
642648
1. A ``db`` querystring option, e.g. redis://localhost?db=0
@@ -693,6 +699,9 @@ def from_url(cls, url, db=None, **kwargs):
693699
except (AttributeError, ValueError):
694700
pass
695701

702+
if url.scheme == 'rediss':
703+
url_options['connection_class'] = SSLConnection
704+
696705
# last shot at the db value
697706
url_options['db'] = int(url_options.get('db', db or 0))
698707

0 commit comments

Comments
 (0)