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) {
2525 }
2626 opt .InitAddress = []string {strings .TrimSpace (u .Path )}
2727 case "rediss" :
28- opt .TLSConfig = & tls.Config {}
28+ opt .TLSConfig = & tls.Config {
29+ MinVersion : tls .VersionTLS12 ,
30+ }
2931 case "redis" :
3032 default :
3133 return opt , fmt .Errorf ("redis: invalid URL scheme: %s" , u .Scheme )
@@ -42,6 +44,9 @@ func ParseURL(str string) (opt ClientOption, err error) {
4244 port = "6379"
4345 }
4446 opt .InitAddress = []string {net .JoinHostPort (host , port )}
47+ if opt .TLSConfig != nil {
48+ opt .TLSConfig .ServerName = host
49+ }
4550 }
4651 if u .User != nil {
4752 opt .Username = u .User .Username ()
Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ func TestParseURL(t *testing.T) {
5757 if opt , err := ParseURL ("redis://?master_set=0" ); opt .Sentinel .MasterSet != "0" {
5858 t .Fatalf ("unexpected %v %v" , opt , err )
5959 }
60+ if opt , err := ParseURL ("rediss://myhost:6379" ); err != nil || opt .TLSConfig .ServerName != "myhost" {
61+ t .Fatalf ("unexpected %v %v" , opt , err )
62+ }
6063}
6164
6265func TestMustParseURL (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments