fix(redis): verify TLS server certificates#5648
Open
kevwan wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens core/stores/redis TLS behavior by switching Redis TLS to Go’s default certificate + hostname verification, adding a way to supply custom tls.Config, and ensuring the connection cache won’t reuse plaintext vs TLS (or different TLS policies) for the same address.
Changes:
- Replace the previous TLS behavior (which implicitly disabled verification) with secure TLS defaults and add
WithTLSConfigto customize CA pools / ServerName / client certs. - Add
TlsInsecureSkipVerifyto Redis config as an explicit migration escape hatch. - Adjust client/cluster connection caching keys to separate plaintext vs TLS clients, and add/extend tests around TLS configuration behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/stores/redis/redis.go | Introduces TLS config fields/options, TlsInsecureSkipVerify wiring, and a new manager cache key that includes TLS policy. |
| core/stores/redis/redisclientmanager.go | Uses TLS config cloning and the new manager key when creating/caching node clients. |
| core/stores/redis/redisclustermanager.go | Uses TLS config cloning and the new manager key when creating/caching cluster clients. |
| core/stores/redis/conf.go | Adds TlsInsecureSkipVerify to RedisConf and maps it to TLS options. |
| core/stores/redis/redisclientmanager_test.go | Adds tests for WithTLS, WithTLSConfig, cloning behavior, and cache separation by TLS policy. |
| core/stores/redis/redisclustermanager_test.go | Updates cluster test to use TLS config and asserts verification isn’t disabled. |
| core/stores/redis/redis_test.go | Adjusts TLS-related test setup to avoid blocking connection checks when TLS is enabled. |
| core/stores/redis/conf_test.go | Adds tests validating secure vs insecure TLS behavior from RedisConf/NewRedis. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
WithTLSConfigfor custom CA pools, server names, and client certificatesTlsInsecureSkipVerifyas an explicit migration escape hatch for legacy self-signed deploymentsCompatibility
This intentionally changes
Tls: trueandWithTLS()to verify server certificates. Deployments using an untrusted self-signed certificate or a hostname mismatch must configure the appropriate CA throughWithTLSConfig, or temporarily setTlsInsecureSkipVerify: true.Verification
go test ./core/stores/redis -count=1go test -race ./core/stores/redis -count=1go vet ./core/stores/redisFixes #5644