Skip to content

Commit d92d20e

Browse files
committed
feat: Add "skip_verify" to Sentinel
Same as 3d4310a but for FailoverOptions. Signed-off-by: Julien Riou <[email protected]>
1 parent 9c1655e commit d92d20e

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
@@ -271,6 +271,7 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
271271
// URL attributes (scheme, host, userinfo, resp.), query parameters using these
272272
// names will be treated as unknown parameters
273273
// - unknown parameter names will result in an error
274+
// - use "skip_verify=true" to ignore TLS certificate validation
274275
//
275276
// Example:
276277
//
@@ -378,6 +379,10 @@ func setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions,
378379
o.SentinelAddrs = append(o.SentinelAddrs, net.JoinHostPort(h, p))
379380
}
380381

382+
if o.TLSConfig != nil && q.has("skip_verify") {
383+
o.TLSConfig.InsecureSkipVerify = q.bool("skip_verify")
384+
}
385+
381386
// any parameters left?
382387
if r := q.remaining(); len(r) > 0 {
383388
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)