Skip to content

Commit 02de89f

Browse files
committed
SSL/TLS documentation
1 parent a0b663c commit 02de89f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,46 @@ end
222222

223223
See lib/redis/errors.rb for information about what exceptions are possible.
224224

225+
## SSL/TLS Support
226+
227+
This library supports natively terminating client side SSL/TLS connections
228+
when talking to Redis via a server-side proxy such as [stunnel], [hitch],
229+
or [ghostunnel].
230+
231+
To enable SSL support, pass the `:ssl => :true` option when configuring the
232+
Redis client, or pass in `:url => "rediss://..."` (like HTTPS for Redis).
233+
You will also need to pass in an `:ssl_params => { ... }` hash used to
234+
configure the `OpenSSL::SSL::SSLContext` object used for the connection:
235+
236+
```ruby
237+
redis = Redis.new(:url => "rediss://:[email protected]:6381/15", :ssl_params => { :ca_file => "/path/to/ca.crt" })
238+
```
239+
240+
The options given to `:ssl_params` are passed directly to the
241+
`OpenSSL::SSL::SSLContext#set_params` method and can be any valid attribute
242+
of the SSL context. Please see the [OpenSSL::SSL::SSLContext documentation]
243+
for all of the available attributes.
244+
245+
Here is an example of passing in params that can be used for SSL client
246+
certificate authentication (a.k.a. mutual TLS):
247+
248+
```ruby
249+
redis = Redis.new(
250+
:url => "rediss://:[email protected]:6381/15",
251+
:ssl_params => {
252+
:ca_file => "/path/to/ca.crt",
253+
:cert => OpenSSL::X509::Certificate.new(File.read("client.crt")),
254+
:key => OpenSSL::PKey::RSA.new(File.read("client.key"))
255+
}
256+
)
257+
```
258+
259+
[stunnel]: https://www.stunnel.org/
260+
[hitch]: https://hitch-tls.org/
261+
[ghostunnel]: https://github.com/square/ghostunnel
262+
[OpenSSL::SSL::SSLContext documentation]: http://ruby-doc.org/stdlib-2.3.0/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html
263+
264+
*NOTE:* SSL is only supported by the default "Ruby" driver
225265

226266
## Expert-Mode Options
227267

0 commit comments

Comments
 (0)