Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add SSL MinVersion #8456

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ linters-settings:
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
excludes:
- G402
- G404
# TODO: enable G115 after fixing the issues
- G115
Expand Down
8 changes: 4 additions & 4 deletions client/pd_service_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,17 @@ func TestServiceClientScheme(t *testing.T) {
re.Equal("http://127.0.0.1:2379", cli.GetURL())
cli = newPDServiceClient(modifyURLScheme("http://127.0.0.1:2379", nil), modifyURLScheme("127.0.0.1:2379", nil), nil, false)
re.Equal("http://127.0.0.1:2379", cli.GetURL())
cli = newPDServiceClient(modifyURLScheme("127.0.0.1:2379", &tls.Config{}), modifyURLScheme("127.0.0.1:2379", &tls.Config{}), nil, false)
cli = newPDServiceClient(modifyURLScheme("127.0.0.1:2379", &tls.Config{MinVersion: tls.VersionTLS12}), modifyURLScheme("127.0.0.1:2379", &tls.Config{MinVersion: tls.VersionTLS12}), nil, false)
re.Equal("https://127.0.0.1:2379", cli.GetURL())
cli = newPDServiceClient(modifyURLScheme("https://127.0.0.1:2379", &tls.Config{}), modifyURLScheme("127.0.0.1:2379", &tls.Config{}), nil, false)
cli = newPDServiceClient(modifyURLScheme("https://127.0.0.1:2379", &tls.Config{MinVersion: tls.VersionTLS12}), modifyURLScheme("127.0.0.1:2379", &tls.Config{MinVersion: tls.VersionTLS12}), nil, false)
re.Equal("https://127.0.0.1:2379", cli.GetURL())
cli = newPDServiceClient(modifyURLScheme("http://127.0.0.1:2379", &tls.Config{}), modifyURLScheme("127.0.0.1:2379", &tls.Config{}), nil, false)
cli = newPDServiceClient(modifyURLScheme("http://127.0.0.1:2379", &tls.Config{MinVersion: tls.VersionTLS12}), modifyURLScheme("127.0.0.1:2379", &tls.Config{MinVersion: tls.VersionTLS12}), nil, false)
re.Equal("https://127.0.0.1:2379", cli.GetURL())
}

func TestSchemeFunction(t *testing.T) {
re := require.New(t)
tlsCfg := &tls.Config{}
tlsCfg := &tls.Config{MinVersion: tls.VersionTLS12}

endpoints1 := []string{
"http://tc-pd:2379",
Expand Down
3 changes: 2 additions & 1 deletion client/tlsutil/tlsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
return nil, err
}
} else {
cfg = &tls.Config{ServerName: info.serverName}
cfg = &tls.Config{ServerName: info.serverName, MinVersion: tls.VersionTLS12}

Check warning on line 82 in client/tlsutil/tlsconfig.go

View check run for this annotation

Codecov / codecov/patch

client/tlsutil/tlsconfig.go#L82

Added line #L82 was not covered by tests
}
cfg.InsecureSkipVerify = info.insecureSkipVerify

Expand Down Expand Up @@ -190,6 +190,7 @@
Certificates: certificates,
RootCAs: certPool,
NextProtos: []string{"h2", "http/1.1"}, // specify `h2` to let Go use HTTP/2.
MinVersion: tls.VersionTLS12,
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/utils/grpcutil/grpcutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (s TLSConfig) ToTLSConfig() (*tls.Config, error) {
Certificates: certificates,
RootCAs: certPool,
NextProtos: []string{"h2", "http/1.1"}, // specify `h2` to let Go use HTTP/2.
MinVersion: tls.VersionTLS12,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/netutil/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestIsEnableHttps(t *testing.T) {
httpClient = &http.Client{
Transport: &http.Transport{
DisableKeepAlives: true,
TLSClientConfig: &tls.Config{},
TLSClientConfig: &tls.Config{MinVersion: tls.VersionTLS12},
},
}
re.False(IsEnableHTTPS(httpClient))
Expand Down