Skip to content

Commit

Permalink
fix broken insecureskipverify handling in rediss connection uris (go-…
Browse files Browse the repository at this point in the history
…gitea#20967)

fixes regression go-gitea#19213
  • Loading branch information
ajgon authored Aug 29, 2022
1 parent 4bd3b05 commit 354ebe4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/nosql/manager_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func getRedisTLSOptions(uri *url.URL) *tls.Config {

if len(skipverify) > 0 {
skipverify, err := strconv.ParseBool(skipverify)
if err != nil {
if err == nil {
tlsConfig.InsecureSkipVerify = skipverify
}
}
Expand All @@ -254,7 +254,7 @@ func getRedisTLSOptions(uri *url.URL) *tls.Config {

if len(insecureskipverify) > 0 {
insecureskipverify, err := strconv.ParseBool(insecureskipverify)
if err != nil {
if err == nil {
tlsConfig.InsecureSkipVerify = insecureskipverify
}
}
Expand Down
18 changes: 18 additions & 0 deletions modules/nosql/manager_redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ func TestRedisPasswordOpt(t *testing.T) {
}
}

func TestSkipVerifyOpt(t *testing.T) {
uri, _ := url.Parse("rediss://myredis/0?skipverify=true")
tlsConfig := getRedisTLSOptions(uri)

if !tlsConfig.InsecureSkipVerify {
t.Fail()
}
}

func TestInsecureSkipVerifyOpt(t *testing.T) {
uri, _ := url.Parse("rediss://myredis/0?insecureskipverify=true")
tlsConfig := getRedisTLSOptions(uri)

if !tlsConfig.InsecureSkipVerify {
t.Fail()
}
}

func TestRedisSentinelUsernameOpt(t *testing.T) {
uri, _ := url.Parse("redis+sentinel://redis:password@myredis/0?sentinelusername=suser&sentinelpassword=spass")
opts := getRedisOptions(uri).Failover()
Expand Down

0 comments on commit 354ebe4

Please sign in to comment.