diff options
author | Igor Rzegocki <ajgon@users.noreply.github.com> | 2022-08-29 16:38:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 16:38:49 +0200 |
commit | 354ebe46100199d82d4feca1d7bc505778aba69d (patch) | |
tree | 3f44b17d9f498b083f591e07d40645982f929559 /modules/nosql | |
parent | 4bd3b05b6279ccb0a7bd165707aa2881ab90b483 (diff) | |
download | gitea-354ebe46100199d82d4feca1d7bc505778aba69d.tar.gz gitea-354ebe46100199d82d4feca1d7bc505778aba69d.zip |
fix broken insecureskipverify handling in rediss connection uris (#20967)
fixes regression #19213
Diffstat (limited to 'modules/nosql')
-rw-r--r-- | modules/nosql/manager_redis.go | 4 | ||||
-rw-r--r-- | modules/nosql/manager_redis_test.go | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/modules/nosql/manager_redis.go b/modules/nosql/manager_redis.go index 3b2ad75b41..f7d5a72ed2 100644 --- a/modules/nosql/manager_redis.go +++ b/modules/nosql/manager_redis.go @@ -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 } } @@ -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 } } diff --git a/modules/nosql/manager_redis_test.go b/modules/nosql/manager_redis_test.go index 3d94532135..99a8856f1e 100644 --- a/modules/nosql/manager_redis_test.go +++ b/modules/nosql/manager_redis_test.go @@ -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() |