Skip to content

Commit 162c3fb

Browse files
authored
feat: Add "skip_verify" to Sentinel (#3428)
Same as 3d4310a but for FailoverOptions. Signed-off-by: Julien Riou <[email protected]>
1 parent 90923b3 commit 162c3fb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sentinel.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
272272
// URL attributes (scheme, host, userinfo, resp.), query parameters using these
273273
// names will be treated as unknown parameters
274274
// - unknown parameter names will result in an error
275+
// - use "skip_verify=true" to ignore TLS certificate validation
275276
//
276277
// Example:
277278
//
@@ -379,6 +380,10 @@ func setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions,
379380
o.SentinelAddrs = append(o.SentinelAddrs, net.JoinHostPort(h, p))
380381
}
381382

383+
if o.TLSConfig != nil && q.has("skip_verify") {
384+
o.TLSConfig.InsecureSkipVerify = q.bool("skip_verify")
385+
}
386+
382387
// any parameters left?
383388
if r := q.remaining(); len(r) > 0 {
384389
return nil, fmt.Errorf("redis: unexpected option: %s", strings.Join(r, ", "))

sentinel_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,14 @@ func TestParseFailoverURL(t *testing.T) {
431431
ServerName: "localhost",
432432
}},
433433
},
434+
{
435+
url: "rediss://localhost:6379/5?master_name=test&skip_verify=true",
436+
o: &redis.FailoverOptions{SentinelAddrs: []string{"localhost:6379"}, MasterName: "test", DB: 5,
437+
TLSConfig: &tls.Config{
438+
ServerName: "localhost",
439+
InsecureSkipVerify: true,
440+
}},
441+
},
434442
{
435443
url: "redis://localhost:6379/5?master_name=test&db=2",
436444
o: &redis.FailoverOptions{SentinelAddrs: []string{"localhost:6379"}, MasterName: "test", DB: 2},

0 commit comments

Comments
 (0)