redis-store / redis-actionpack

Redis stores for ActionPack
http://redis-store.org/redis-actionpack
MIT License
76 stars 44 forks source link

Passing ssl_params in session_store not working #45

Open carlosbalsas opened 1 year ago

carlosbalsas commented 1 year ago

I have an app in Heroku, I'm trying to do the code below, but seems ssl_params not passing... because I still get the OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 peeraddr=52.214.49.109:23399 state=error: certificate verify failed (self-signed certificate in certificate chain))

Rails.application.config.session_store :redis_store,
                                       url: session_url,
                                       expire_after: 1.day,
                                       key: '_dokspot_session',
                                       domain: domain,
                                       tld_length: tld_length,
                                       secure: secure,
                                       ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }

Any advice?

PS: If I use the cookie_store (default for session_store) it works without a problem so the problem is using Redis with session_store.

DaichiSaito commented 1 year ago

How about the code below?

Rails.application.config.session_store :redis_store,
                                       servers: {
                                         url: ENV['REDIS_URL'],
                                         ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
                                       }
                                       expire_after: 1.day
rjherrera commented 4 days ago

I came to this repo to propose a change in the README.md regarding the servers option and I found the great answer by @DaichiSaito, which basically does the same as I did to solve the issue I was having with Heroku and Redis.

I think the documentation could be clearer in stating the possibilities for the servers option.

What I did is very similar to what DaichiSaito proposes.

redis_config = Rails.application.config_for(:redis)

Rails.application.config.session_store :redis_store,
                                       servers: [redis_config],
                                       expire_after: 30.days,
                                       key: '_app_session'

which has the benefit of reusing the redis config found in my redis.yml file, to centralize the ssl_params setting and all other options.

Maybe the servers option should say something in the lines of "is an Array of Redis server URLs that we will attempt to find data from, it can also be an array of hashes with the options accepted by the redis-client initialization".

Do you guys agree with this change? Should I create a PR?