diff --git a/nodebuilder/core/config.go b/nodebuilder/core/config.go index 7beaa4b192..53472069de 100644 --- a/nodebuilder/core/config.go +++ b/nodebuilder/core/config.go @@ -18,12 +18,8 @@ type Config struct { IP string Port string // TLSEnabled specifies whether the connection is secure or not. - // PLEASE NOTE: it should be set to true in order to handle TLSPath and/or XTokenPath. + // PLEASE NOTE: it should be set to true in order to handle XTokenPath. TLSEnabled bool - // TLSPath specifies the directory path where the TLS certificates are stored. - // It should not include file names('cert.pem' and 'key.pem'). - // If left empty, the client will be configured for an insecure (non-TLS) connection. - TLSPath string // XTokenPath specifies the path to the directory with JSON file containing the X-Token for gRPC authentication. // The JSON file should have a key-value pair where the key is "x-token" and the value is the authentication token. // If left empty, the client will not include the X-Token in its requests. diff --git a/nodebuilder/core/flags.go b/nodebuilder/core/flags.go index a2c36f4e3d..8b0ce04cd8 100644 --- a/nodebuilder/core/flags.go +++ b/nodebuilder/core/flags.go @@ -11,7 +11,6 @@ var ( coreFlag = "core.ip" coreGRPCFlag = "core.grpc.port" coreTLS = "core.tls" - coreTLSPathFlag = "core.tls.path" coreXTokenPathFlag = "core.xtoken.path" //nolint:gosec ) @@ -36,15 +35,6 @@ func Flags() *flag.FlagSet { false, "Specifies whether TLS is enabled or not. Default: false", ) - flags.String( - coreTLSPathFlag, - "", - "specifies the directory path where the TLS certificates are stored. "+ - "It should not include file names ('cert.pem' and 'key.pem'). "+ - "NOTE: the path is parsed only if coreTLS enabled."+ - "If left empty, with disabled coreTLS, the client will be configured for "+ - "an insecure (non-TLS) connection", - ) flags.String( coreXTokenPathFlag, "", @@ -81,11 +71,6 @@ func ParseFlags( if enabled { cfg.TLSEnabled = true - if cmd.Flag(coreTLSPathFlag).Changed { - path := cmd.Flag(coreTLSPathFlag).Value.String() - cfg.TLSPath = path - } - if cmd.Flag(coreXTokenPathFlag).Changed { path := cmd.Flag(coreXTokenPathFlag).Value.String() cfg.XTokenPath = path diff --git a/nodebuilder/core/tls.go b/nodebuilder/core/tls.go index da8b7b1267..96e71c5cee 100644 --- a/nodebuilder/core/tls.go +++ b/nodebuilder/core/tls.go @@ -20,33 +20,6 @@ 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. -// If either file is missing, it returns an os.ErrNotExist error. -// If the files exist, it loads the X.509 key pair from the specified files and sets up a tls.Config. -// Parameters: -// * tlsPath: The directory path where the TLS certificate ("cert.pem") and key ("key.pem") files are located. -// Returns: -// * A tls.Config structure configured with the provided certificate and key. -// * An error if the certificate or key file does not exist, or if loading the key pair fails. -func TLS(tlsPath string) (*tls.Config, error) { - certPath := filepath.Join(tlsPath, cert) - keyPath := filepath.Join(tlsPath, key) - exist := utils.Exists(certPath) && utils.Exists(keyPath) - if !exist { - return nil, os.ErrNotExist - } - - cfg := EmptyTLSConfig() - cert, err := tls.LoadX509KeyPair(certPath, keyPath) - if err != nil { - return nil, err - } - cfg.Certificates = append(cfg.Certificates, cert) - return cfg, nil -} - type AuthToken struct { Token string `json:"x-token"` } diff --git a/nodebuilder/state/core.go b/nodebuilder/state/core.go index c8abed9f04..09fad9d005 100644 --- a/nodebuilder/state/core.go +++ b/nodebuilder/state/core.go @@ -34,16 +34,8 @@ func coreAccessor( error, ) { if corecfg.TLSEnabled { - tlsCfg, err := core.TLS(corecfg.TLSPath) - switch { - case err == nil: - case errors.Is(err, os.ErrNotExist): - // set an empty config if path is empty under `TLSEnabled=true` - tlsCfg = core.EmptyTLSConfig() - default: - return nil, nil, nil, err - } - + // set an empty config if path is empty under `TLSEnabled=true` + tlsCfg := core.EmptyTLSConfig() xtoken, err := core.XToken(corecfg.XTokenPath) if err != nil && !errors.Is(err, os.ErrNotExist) { return nil, nil, nil, err