mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	fix broken insecureskipverify handling in rediss connection uris (#20967)
fixes regression #19213
This commit is contained in:
		| @@ -245,7 +245,7 @@ func getRedisTLSOptions(uri *url.URL) *tls.Config { | |||||||
|  |  | ||||||
| 	if len(skipverify) > 0 { | 	if len(skipverify) > 0 { | ||||||
| 		skipverify, err := strconv.ParseBool(skipverify) | 		skipverify, err := strconv.ParseBool(skipverify) | ||||||
| 		if err != nil { | 		if err == nil { | ||||||
| 			tlsConfig.InsecureSkipVerify = skipverify | 			tlsConfig.InsecureSkipVerify = skipverify | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -254,7 +254,7 @@ func getRedisTLSOptions(uri *url.URL) *tls.Config { | |||||||
|  |  | ||||||
| 	if len(insecureskipverify) > 0 { | 	if len(insecureskipverify) > 0 { | ||||||
| 		insecureskipverify, err := strconv.ParseBool(insecureskipverify) | 		insecureskipverify, err := strconv.ParseBool(insecureskipverify) | ||||||
| 		if err != nil { | 		if err == nil { | ||||||
| 			tlsConfig.InsecureSkipVerify = insecureskipverify | 			tlsConfig.InsecureSkipVerify = insecureskipverify | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -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) { | func TestRedisSentinelUsernameOpt(t *testing.T) { | ||||||
| 	uri, _ := url.Parse("redis+sentinel://redis:password@myredis/0?sentinelusername=suser&sentinelpassword=spass") | 	uri, _ := url.Parse("redis+sentinel://redis:password@myredis/0?sentinelusername=suser&sentinelpassword=spass") | ||||||
| 	opts := getRedisOptions(uri).Failover() | 	opts := getRedisOptions(uri).Failover() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user