Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Nov 19, 2024
1 parent 82c92e8 commit 06bab7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion nodebuilder/core/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions nodebuilder/state/core.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package state

import (
"crypto/tls"
"errors"
"os"

Expand Down Expand Up @@ -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
}
Expand All @@ -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...)

Expand Down

0 comments on commit 06bab7b

Please sign in to comment.