Skip to content

Commit f98b5f6

Browse files
committed
Allow 'rediss' scheme to define whether SSL is enabled
If the URL uses the 'rediss' scheme, SSL should be enabled. This follows the behaviour of Redix standalone and embedded in other libraries.
1 parent 91df117 commit f98b5f6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Option | Description
3333
`:host` | The redis-server host IP | `"127.0.0.1"` |
3434
`:port` | The redis-server port | `6379` |
3535
`:password` | The redis-server password | `""` |
36+
`:ssl` | The redis-server SSL flag | `false` |
3637
`:compression_level` | Compression level applied to serialized terms (`0` - none, `9` - highest) | `0` |
3738
`:socket_opts` | The redis-server network layer options | `[]` |
3839

lib/phoenix_pubsub_redis/redis.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Phoenix.PubSub.Redis do
2323
* `:host` - The redis-server host IP, defaults `"127.0.0.1"`
2424
* `:port` - The redis-server port, defaults `6379`
2525
* `:password` - The redis-server password, defaults `""`
26-
* `:ssl` - The redis-server ssl option, defaults `false`
26+
* `:ssl` - The redis-server ssl option, defaults `false`, unless the URL scheme is `rediss`
2727
* `:redis_pool_size` - The size of the redis connection pool. Defaults `5`
2828
* `:compression_level` - Compression level applied to serialized terms - from `0` (no compression), to `9` (highest). Defaults `0`
2929
* `:socket_opts` - List of options that are passed to the network layer when connecting to the Redis server. Default `[]`
@@ -111,9 +111,12 @@ defmodule Phoenix.PubSub.Redis do
111111
[username, password] -> [username: username, password: password]
112112
end
113113

114+
ssl = info.scheme == "rediss"
115+
114116
opts
115117
|> Keyword.merge(user_opts)
116118
|> Keyword.merge(host: info.host, port: info.port || @defaults[:port])
119+
|> Keyword.put(:ssl, ssl)
117120
end
118121

119122
defp validate_node_name!(node_name) do

0 commit comments

Comments
 (0)