Skip to content

Commit 62a56aa

Browse files
committed
fix: update test expectations for consistent TLS 1.2 enforcement
After pulling the latest security fixes, update test cases to match the new security-first behavior where all rediss:// URLs enforce TLS 1.2 minimum: **Changes Made**: 1. **Cluster Test Fixes**: - Updated ParseRedissURL test to expect MinVersion: tls.VersionTLS12 - Updated MultipleRedissURLs test to expect MinVersion: tls.VersionTLS12 - Updated RedissTLSCert test to expect MinVersion: tls.VersionTLS12 - Updated RedissSkipVerify test to expect MinVersion: tls.VersionTLS12 2. **Sentinel Client Consistency**: - Made sentinel client behavior consistent with single/cluster clients - Always set MinVersion to TLS 1.2 for rediss:// URLs, even when not specified - Matches the security-first approach across all client types **Security Behavior**: - All rediss:// URLs now enforce minimum TLS 1.2 by default - Consistent security posture across single, cluster, and sentinel clients - No breaking changes for secure configurations - Enhanced security for all TLS connections **Test Results**: - All single client tests pass ✅ - All builds successful ✅ - Consistent behavior across all client types ✅ This ensures uniform security enforcement and test expectations across the entire go-redis library.
1 parent 2614ca0 commit 62a56aa

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

osscluster_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
16371637
}, {
16381638
test: "ParseRedissURL",
16391639
url: "rediss://localhost:123",
1640-
o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, TLSConfig: &tls.Config{ServerName: "localhost"}},
1640+
o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, TLSConfig: &tls.Config{ServerName: "localhost", MinVersion: tls.VersionTLS12}},
16411641
}, {
16421642
test: "MissingRedisPort",
16431643
url: "redis://localhost",
@@ -1653,19 +1653,19 @@ EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
16531653
}, {
16541654
test: "MultipleRedissURLs",
16551655
url: "rediss://localhost:123?addr=localhost:1234&addr=localhost:12345",
1656-
o: &redis.ClusterOptions{Addrs: []string{"localhost:123", "localhost:1234", "localhost:12345"}, TLSConfig: &tls.Config{ServerName: "localhost"}},
1656+
o: &redis.ClusterOptions{Addrs: []string{"localhost:123", "localhost:1234", "localhost:12345"}, TLSConfig: &tls.Config{ServerName: "localhost", MinVersion: tls.VersionTLS12}},
16571657
}, {
16581658
test: "RedissTLSParams",
16591659
url: "rediss://localhost:123?tls_server_name=abc&tls_min_version=771&tls_max_version=772&skip_verify=true",
16601660
o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, TLSConfig: &tls.Config{ServerName: "abc", MinVersion: 771, MaxVersion: 772, InsecureSkipVerify: true}},
16611661
}, {
16621662
test: "RedissTLSCert",
16631663
url: "rediss://localhost:123?tls_cert_file=./testdata/testcert.pem&tls_key_file=./testdata/testkey.pem",
1664-
o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, TLSConfig: &tls.Config{ServerName: "localhost", Certificates: []tls.Certificate{testCert}}},
1664+
o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, TLSConfig: &tls.Config{ServerName: "localhost", MinVersion: tls.VersionTLS12, Certificates: []tls.Certificate{testCert}}},
16651665
}, {
16661666
test: "RedissSkipVerify",
16671667
url: "rediss://localhost:123?skip_verify=true",
1668-
o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, TLSConfig: &tls.Config{ServerName: "localhost", InsecureSkipVerify: true}},
1668+
o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, TLSConfig: &tls.Config{ServerName: "localhost", MinVersion: tls.VersionTLS12, InsecureSkipVerify: true}},
16691669
}, {
16701670
test: "OnlyPassword",
16711671
url: "redis://:bar@localhost:123",

sentinel.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,17 @@ func setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions,
439439
if minVer < 0 || minVer > 65535 {
440440
return nil, fmt.Errorf("redis: invalid tls_min_version: %d (must be between 0 and 65535)", minVer)
441441
}
442-
// Handle TLS version setting securely
442+
// Always enforce TLS 1.2 as minimum
443443
if minVer == 0 {
444-
// Explicitly set MinVersion to TLS 1.2 for security
445444
o.TLSConfig.MinVersion = tls.VersionTLS12
446445
} else if minVer < int(tls.VersionTLS12) {
447446
return nil, fmt.Errorf("redis: tls_min_version %d is insecure (minimum allowed is TLS 1.2: %d)", minVer, tls.VersionTLS12)
448447
} else {
449448
o.TLSConfig.MinVersion = uint16(minVer)
450449
}
450+
} else {
451+
// If not specified, always set minimum to TLS 1.2
452+
o.TLSConfig.MinVersion = tls.VersionTLS12
451453
}
452454
if q.has("tls_max_version") {
453455
maxVer := q.int("tls_max_version")

0 commit comments

Comments
 (0)