Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to configure Redis (to disable SSL verification) #1372

Closed
markedmondson opened this issue Oct 22, 2024 · 4 comments · Fixed by #1373
Closed

No way to configure Redis (to disable SSL verification) #1372

markedmondson opened this issue Oct 22, 2024 · 4 comments · Fixed by #1373

Comments

@markedmondson
Copy link
Contributor

There is no way to configure Redis within Shipit (or PubStubHub), namely, change ssl_params on the initializer. Our problem specifically came from Heroku upgrading us to Redis 6.0. 6.0 requires TLS but Heroku doesn't support it (as routing it internal) so rejects the certificate, the workaround is to disable SSL verification.

See: https://help.heroku.com/HC0F8CUS/heroku-key-value-store-connection-issues and https://devcenter.heroku.com/articles/connecting-heroku-redis#external-connections

We ended up with these unfortunate monkey patches. I'll try and get a contribution together.

require 'shipit'
require 'active_support'

module ShipitExtension
  def redis
    @redis_ext ||= Redis.new(
      url: redis_url.to_s.presence,
      logger: Rails.logger,
      reconnect_attempts: 3,
      reconnect_delay: 0.5,
      reconnect_delay_max: 1,
      ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
    )
  end
end

ActiveSupport::Reloader.to_prepare { Shipit.prepend ShipitExtension }

require 'pubsubstub'

module PubsubstubExtension
  def new_redis
    Redis.new(
      url: redis_url,
      reconnect_attempts: 3,
      ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
    )
  end
end

Pubsubstub.singleton_class.prepend PubsubstubExtension
Pubsubstub.instance_variable_set('@redis', nil)
@markedmondson markedmondson changed the title No way to configure Redis No way to configure Redis (to disable SSL verification) Oct 22, 2024
@casperisfine
Copy link
Contributor

Yeah, we should define Shipit.redis= so that you can configure the client as much as you want.

@casperisfine
Copy link
Contributor

PR welcome.

@markedmondson
Copy link
Contributor Author

Done - what about Pubsubstub? I guess we're stuck with the monkey patch there, is it okay to entrench that within the gem too?

@casperisfine
Copy link
Contributor

Yeah, you can send a similar PR to pubsubstub, I'll merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants