From 06bab7b1ff9c4539fba8bef63214d842f387c526 Mon Sep 17 00:00:00 2001 From: vgonkivs Date: Tue, 19 Nov 2024 12:50:03 +0200 Subject: [PATCH] fix lint --- nodebuilder/core/tls.go | 6 +++++- nodebuilder/state/core.go | 11 +++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/nodebuilder/core/tls.go b/nodebuilder/core/tls.go index 3e36e898aa..da8b7b1267 100644 --- a/nodebuilder/core/tls.go +++ b/nodebuilder/core/tls.go @@ -16,6 +16,10 @@ const ( xtoken = "xtoken.json" ) +func EmptyTLSConfig() *tls.Config { + return &tls.Config{MinVersion: tls.VersionTLS12} +} + // TLS creates a TLS configuration using the certificate and key files from the specified path. // It constructs the full paths to the certificate and key files by joining the provided directory path // with their respective file names. @@ -34,7 +38,7 @@ func TLS(tlsPath string) (*tls.Config, error) { return nil, os.ErrNotExist } - cfg := &tls.Config{} + cfg := EmptyTLSConfig() cert, err := tls.LoadX509KeyPair(certPath, keyPath) if err != nil { return nil, err diff --git a/nodebuilder/state/core.go b/nodebuilder/state/core.go index 49aa3febf6..e32822dfc1 100644 --- a/nodebuilder/state/core.go +++ b/nodebuilder/state/core.go @@ -1,7 +1,6 @@ package state import ( - "crypto/tls" "errors" "os" @@ -34,14 +33,13 @@ func coreAccessor( *modfraud.ServiceBreaker[*state.CoreAccessor, *header.ExtendedHeader], error, ) { - if corecfg.TLSEnabled { tlsCfg, err := core.TLS(corecfg.TLSPath) - switch err { - case nil: - case os.ErrNotExist: + switch { + case err == nil: + case errors.Is(err, os.ErrNotExist): // set an empty config if path is empty under `TLSEnabled=true` - tlsCfg = &tls.Config{} + tlsCfg = core.EmptyTLSConfig() default: return nil, nil, nil, err } @@ -52,6 +50,7 @@ func coreAccessor( } opts = append(opts, state.WithTLSConfig(tlsCfg), state.WithXToken(xtoken)) } + ca, err := state.NewCoreAccessor(keyring, string(keyname), sync, corecfg.IP, corecfg.GRPCPort, network.String(), opts...)