Skip to content

Commit

Permalink
fix: support TLS connections to Redis (#1285)
Browse files Browse the repository at this point in the history
<!--
Thank you for contributing to the project! 💜
Please make sure to:
- Chat with us first if this is a big change
  - Open a new issue (or comment on an existing one)
- We want to make sure you don't spend time implementing something we
might have to say No to
- Add unit tests
- Mention any relevant issues in the PR description (e.g. "Fixes #123")

Please see our [OSS process
document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#)
to get an idea of how we operate.
-->

Currently, we are not setting the tls config for go-redis even through
we do have `UseTLS` configuration option.

- log the pubsub publish error
- configure redis client tls
  • Loading branch information
VinozzZ committed Aug 19, 2024
1 parent e6310cd commit 0a79fb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/peer/pubsub_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ func (p *RedisPubsubPeers) stop() {
p.Logger.Error().Logf("failed to get public address")
return
}

err = p.PubSub.Publish(context.Background(), "peers", newPeerCommand(Unregister, myaddr).marshal())
if err != nil {
p.Logger.Error().WithFields(map[string]interface{}{
"error": err,
"hostaddress": myaddr,
}).Logf("failed to publish peer address")
}

}

func (p *RedisPubsubPeers) GetPeers() ([]string, error) {
Expand Down
16 changes: 5 additions & 11 deletions pubsub/pubsub_goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,15 @@ func (ps *GoRedisPubSub) Start() error {
options.Username = username
options.Password = pw
options.DB = ps.Config.GetRedisDatabase()
useTLS := ps.Config.GetUseTLS()
tlsInsecure := ps.Config.GetUseTLSInsecure()
if useTLS {
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12,
}

if tlsInsecure {
tlsConfig.InsecureSkipVerify = true
if ps.Config.GetUseTLS() {
options.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
InsecureSkipVerify: ps.Config.GetUseTLSInsecure(),
}

options.TLSConfig = tlsConfig
}

}

client := redis.NewUniversalClient(options)

// if an authcode was provided, use it to authenticate the connection
Expand Down

0 comments on commit 0a79fb4

Please sign in to comment.