redis / hiredis-rb

Ruby wrapper for hiredis
BSD 3-Clause "New" or "Revised" License
319 stars 90 forks source link

Support SSL connections #87

Closed stanhu closed 2 years ago

stanhu commented 2 years ago

To do:

  1. Currently if SSL peer verification fails, this C extension seg faults in rb_sys_fail(0). This C extension should never seg fault.
  2. Disable SSL peer verification if no certificates are configured. Requires https://github.com/redis/hiredis/pull/1085.
  3. Update vendored hiredis-rb with those changes.
  4. Update redis-rb with this change:
diff --git a/lib/redis/connection/hiredis.rb b/lib/redis/connection/hiredis.rb
index 1dbb6a3..5d23600 100644
--- a/lib/redis/connection/hiredis.rb
+++ b/lib/redis/connection/hiredis.rb
@@ -15,6 +15,8 @@ class Redis

         if config[:scheme] == "unix"
           connection.connect_unix(config[:path], connect_timeout)
+        elsif config[:scheme] == "rediss" || config[:ssl]
+          connection.connect_ssl(config[:host], config[:port], connect_timeout, config[:ssl_params])
         else
           connection.connect(config[:host], config[:port], connect_timeout)
         end
stanhu commented 2 years ago

I'm going to abandon efforts on this since redis-client fixes all the issues I identified with hiredis-rb: https://github.com/redis/hiredis-rb/issues/58#issuecomment-1211033335

stanhu commented 2 years ago

Closing because redis-rb v5.0 will have hiredis support, and this pull request would need changes for redis-rb in any case.