From d4e187e8fdba463d8f5958cf2cba21915eb9e963 Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Mon, 14 Jul 2025 12:47:01 +0200 Subject: [PATCH] feat: Add "skip_verify" to Sentinel Same as 3d4310ae but for FailoverOptions. Signed-off-by: Julien Riou --- sentinel.go | 5 +++++ sentinel_test.go | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/sentinel.go b/sentinel.go index 04c0f7269..1dcbe69c3 100644 --- a/sentinel.go +++ b/sentinel.go @@ -271,6 +271,7 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions { // URL attributes (scheme, host, userinfo, resp.), query parameters using these // names will be treated as unknown parameters // - unknown parameter names will result in an error +// - use "skip_verify=true" to ignore TLS certificate validation // // Example: // @@ -378,6 +379,10 @@ func setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions, o.SentinelAddrs = append(o.SentinelAddrs, net.JoinHostPort(h, p)) } + if o.TLSConfig != nil && q.has("skip_verify") { + o.TLSConfig.InsecureSkipVerify = q.bool("skip_verify") + } + // any parameters left? if r := q.remaining(); len(r) > 0 { return nil, fmt.Errorf("redis: unexpected option: %s", strings.Join(r, ", ")) diff --git a/sentinel_test.go b/sentinel_test.go index 436895ff2..bfeb28161 100644 --- a/sentinel_test.go +++ b/sentinel_test.go @@ -431,6 +431,14 @@ func TestParseFailoverURL(t *testing.T) { ServerName: "localhost", }}, }, + { + url: "rediss://localhost:6379/5?master_name=test&skip_verify=true", + o: &redis.FailoverOptions{SentinelAddrs: []string{"localhost:6379"}, MasterName: "test", DB: 5, + TLSConfig: &tls.Config{ + ServerName: "localhost", + InsecureSkipVerify: true, + }}, + }, { url: "redis://localhost:6379/5?master_name=test&db=2", o: &redis.FailoverOptions{SentinelAddrs: []string{"localhost:6379"}, MasterName: "test", DB: 2},