Skip to content

Commit 2614ca0

Browse files
Potential fix for code scanning alert no. 14: Insecure TLS configuration
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent a443622 commit 2614ca0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

osscluster.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,17 @@ func setupClusterQueryParams(u *url.URL, o *ClusterOptions) (*ClusterOptions, er
329329
if minVer < 0 || minVer > 65535 {
330330
return nil, fmt.Errorf("redis: invalid tls_min_version: %d (must be between 0 and 65535)", minVer)
331331
}
332-
// Handle TLS version setting securely
332+
// Always enforce TLS 1.2 as minimum
333333
if minVer == 0 {
334-
// Don't set MinVersion, let Go use its secure default
334+
o.TLSConfig.MinVersion = tls.VersionTLS12
335335
} else if minVer < int(tls.VersionTLS12) {
336336
return nil, fmt.Errorf("redis: tls_min_version %d is insecure (minimum allowed is TLS 1.2: %d)", minVer, tls.VersionTLS12)
337337
} else {
338338
o.TLSConfig.MinVersion = uint16(minVer)
339339
}
340+
} else {
341+
// If not specified, always set minimum to TLS 1.2
342+
o.TLSConfig.MinVersion = tls.VersionTLS12
340343
}
341344
if q.has("tls_max_version") {
342345
maxVer := q.int("tls_max_version")

0 commit comments

Comments
 (0)