Skip to content

Commit

Permalink
Allow 'rediss' scheme to define whether SSL is enabled
Browse files Browse the repository at this point in the history
If the URL uses the 'rediss' scheme, SSL should be enabled. This follows the
behaviour of Redix standalone and embedded in other libraries.
  • Loading branch information
tomtaylor committed May 25, 2021
1 parent 91df117 commit 504caa5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/phoenix_pubsub_redis/redis.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule Phoenix.PubSub.Redis do
* `:host` - The redis-server host IP, defaults `"127.0.0.1"`
* `:port` - The redis-server port, defaults `6379`
* `:password` - The redis-server password, defaults `""`
* `:ssl` - The redis-server ssl option, defaults `false`
* `:ssl` - The redis-server ssl option, defaults `false`, unless the URL scheme is `rediss`
* `:redis_pool_size` - The size of the redis connection pool. Defaults `5`
* `:compression_level` - Compression level applied to serialized terms - from `0` (no compression), to `9` (highest). Defaults `0`
* `:socket_opts` - List of options that are passed to the network layer when connecting to the Redis server. Default `[]`
Expand Down Expand Up @@ -111,9 +111,12 @@ defmodule Phoenix.PubSub.Redis do
[username, password] -> [username: username, password: password]
end

ssl = info.scheme == "rediss"

opts
|> Keyword.merge(user_opts)
|> Keyword.merge(host: info.host, port: info.port || @defaults[:port])
|> Keyword.put(:ssl, ssl)
end

defp validate_node_name!(node_name) do
Expand Down

0 comments on commit 504caa5

Please sign in to comment.