Skip to content

feat: Add "skip_verify" to Sentinel #3428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down Expand Up @@ -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, ", "))
Expand Down
8 changes: 8 additions & 0 deletions sentinel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Loading