Skip to content

Commit 1056a85

Browse files
committed
feat(options): Add skip_verify param
When parsing a URL, add a "skip_verify" query param to disable TLS certificate verification. Inspired by various Go drivers: * ClickHouse: https://github.com/ClickHouse/clickhouse-go/blob/v2.30.0/clickhouse_options.go#L259 * MongoDB: https://github.com/mongodb/mongo-go-driver/blob/v2.0.0/x/mongo/driver/connstring/connstring.go#L609 * MySQL: https://github.com/go-sql-driver/mysql/blob/v1.8.1/dsn.go#L175 Signed-off-by: Julien Riou <[email protected]>
1 parent 91dddc2 commit 1056a85

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ func setupConnParams(u *url.URL, o *Options) (*Options, error) {
487487
if q.err != nil {
488488
return nil, q.err
489489
}
490+
if o.TLSConfig != nil && q.has("skip_verify") {
491+
o.TLSConfig.InsecureSkipVerify = q.bool("skip_verify")
492+
}
490493

491494
// any parameters left?
492495
if r := q.remaining(); len(r) > 0 {

options_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func TestParseURL(t *testing.T) {
3030
}, {
3131
url: "rediss://localhost:123",
3232
o: &Options{Addr: "localhost:123", TLSConfig: &tls.Config{ /* no deep comparison */ }},
33+
}, {
34+
url: "rediss://localhost:123/?skip_verify=true",
35+
o: &Options{Addr: "localhost:123", TLSConfig: &tls.Config{InsecureSkipVerify: true}},
3336
}, {
3437
url: "redis://:bar@localhost:123",
3538
o: &Options{Addr: "localhost:123", Password: "bar"},

0 commit comments

Comments
 (0)