File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ func ParseURL(str string) (opt ClientOption, err error) {
25
25
}
26
26
opt .InitAddress = []string {strings .TrimSpace (u .Path )}
27
27
case "rediss" :
28
- opt .TLSConfig = & tls.Config {}
28
+ opt .TLSConfig = & tls.Config {
29
+ MinVersion : tls .VersionTLS12 ,
30
+ }
29
31
case "redis" :
30
32
default :
31
33
return opt , fmt .Errorf ("redis: invalid URL scheme: %s" , u .Scheme )
@@ -42,6 +44,9 @@ func ParseURL(str string) (opt ClientOption, err error) {
42
44
port = "6379"
43
45
}
44
46
opt .InitAddress = []string {net .JoinHostPort (host , port )}
47
+ if opt .TLSConfig != nil {
48
+ opt .TLSConfig .ServerName = host
49
+ }
45
50
}
46
51
if u .User != nil {
47
52
opt .Username = u .User .Username ()
Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ func TestParseURL(t *testing.T) {
57
57
if opt , err := ParseURL ("redis://?master_set=0" ); opt .Sentinel .MasterSet != "0" {
58
58
t .Fatalf ("unexpected %v %v" , opt , err )
59
59
}
60
+ if opt , err := ParseURL ("rediss://myhost:6379" ); err != nil || opt .TLSConfig .ServerName != "myhost" {
61
+ t .Fatalf ("unexpected %v %v" , opt , err )
62
+ }
60
63
}
61
64
62
65
func TestMustParseURL (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments