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

Set minumum TLS version to 1.2 #144

Merged
merged 2 commits into from
May 29, 2022
Merged
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
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ linters-settings:
dupl:
threshold: 150
funlen:
Lines: 110
Lines: 115
Statements: 60
goconst:
min-len: 2
Expand Down
18 changes: 12 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package main
import (
"context"
"crypto/md5"
"crypto/tls"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -156,13 +157,13 @@ func getParentIfname(nseName string) string {
return nif[:kernelmech.LinuxIfMaxLength]
}

func registerGRPCServer(source *workloadapi.X509Source, responderEndpoint *endpoint.Endpoint) *grpc.Server {
func registerGRPCServer(tlsServerConfig *tls.Config, responderEndpoint *endpoint.Endpoint) *grpc.Server {
options := append(
tracing.WithTracing(),
grpc.Creds(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsconfig.MTLSServerConfig(source, source, tlsconfig.AuthorizeAny()),
tlsServerConfig,
),
),
),
Expand All @@ -173,15 +174,15 @@ func registerGRPCServer(source *workloadapi.X509Source, responderEndpoint *endpo
return server
}

func registerEndpoint(ctx context.Context, config *Config, source *workloadapi.X509Source, urlStr string) error {
func registerEndpoint(ctx context.Context, config *Config, tlsClientConfig *tls.Config, urlStr string) error {
clientOptions := append(
tracing.WithTracingDial(),
grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny()),
tlsClientConfig,
),
),
),
Expand Down Expand Up @@ -305,6 +306,11 @@ func main() {
logrus.Fatalf("error getting x509 svid: %+v", err)
}

tlsClientConfig := tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny())
tlsClientConfig.MinVersion = tls.VersionTLS12
tlsServerConfig := tlsconfig.MTLSServerConfig(source, source, tlsconfig.AuthorizeAny())
tlsServerConfig.MinVersion = tls.VersionTLS12

// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 4: creating vlan-vpp-responder ipam")
// ********************************************************************************
Expand All @@ -321,7 +327,7 @@ func main() {
log.FromContext(ctx).Infof("executing phase 6: create grpc server and register vlan-vpp-responder")
// ********************************************************************************

server := registerGRPCServer(source, &responderEndpoint)
server := registerGRPCServer(tlsServerConfig, &responderEndpoint)
tmpDir, err := ioutil.TempDir("", config.Name)
if err != nil {
logrus.Fatalf("error creating tmpDir %+v", err)
Expand All @@ -335,7 +341,7 @@ func main() {
// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 7: register nse with nsm")
// ********************************************************************************
err = registerEndpoint(ctx, config, source, listenOn.String())
err = registerEndpoint(ctx, config, tlsClientConfig, listenOn.String())
if err != nil {
log.FromContext(ctx).Fatalf("failed to connect to registry: %+v", err)
}
Expand Down