Skip to content

Commit 2ffba53

Browse files
committed
remove tlsPath
1 parent 060b520 commit 2ffba53

File tree

4 files changed

+2
-57
lines changed

4 files changed

+2
-57
lines changed

nodebuilder/core/config.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ type Config struct {
1818
IP string
1919
Port string
2020
// TLSEnabled specifies whether the connection is secure or not.
21-
// PLEASE NOTE: it should be set to true in order to handle TLSPath and/or XTokenPath.
21+
// PLEASE NOTE: it should be set to true in order to handle XTokenPath.
2222
TLSEnabled bool
23-
// TLSPath specifies the directory path where the TLS certificates are stored.
24-
// It should not include file names('cert.pem' and 'key.pem').
25-
// If left empty, the client will be configured for an insecure (non-TLS) connection.
26-
TLSPath string
2723
// XTokenPath specifies the path to the directory with JSON file containing the X-Token for gRPC authentication.
2824
// The JSON file should have a key-value pair where the key is "x-token" and the value is the authentication token.
2925
// If left empty, the client will not include the X-Token in its requests.

nodebuilder/core/flags.go

-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var (
1111
coreFlag = "core.ip"
1212
coreGRPCFlag = "core.grpc.port"
1313
coreTLS = "core.tls"
14-
coreTLSPathFlag = "core.tls.path"
1514
coreXTokenPathFlag = "core.xtoken.path" //nolint:gosec
1615
)
1716

@@ -36,15 +35,6 @@ func Flags() *flag.FlagSet {
3635
false,
3736
"Specifies whether TLS is enabled or not. Default: false",
3837
)
39-
flags.String(
40-
coreTLSPathFlag,
41-
"",
42-
"specifies the directory path where the TLS certificates are stored. "+
43-
"It should not include file names ('cert.pem' and 'key.pem'). "+
44-
"NOTE: the path is parsed only if coreTLS enabled."+
45-
"If left empty, with disabled coreTLS, the client will be configured for "+
46-
"an insecure (non-TLS) connection",
47-
)
4838
flags.String(
4939
coreXTokenPathFlag,
5040
"",
@@ -81,11 +71,6 @@ func ParseFlags(
8171

8272
if enabled {
8373
cfg.TLSEnabled = true
84-
if cmd.Flag(coreTLSPathFlag).Changed {
85-
path := cmd.Flag(coreTLSPathFlag).Value.String()
86-
cfg.TLSPath = path
87-
}
88-
8974
if cmd.Flag(coreXTokenPathFlag).Changed {
9075
path := cmd.Flag(coreXTokenPathFlag).Value.String()
9176
cfg.XTokenPath = path

nodebuilder/core/tls.go

-27
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,6 @@ func EmptyTLSConfig() *tls.Config {
2020
return &tls.Config{MinVersion: tls.VersionTLS12}
2121
}
2222

23-
// TLS creates a TLS configuration using the certificate and key files from the specified path.
24-
// It constructs the full paths to the certificate and key files by joining the provided directory path
25-
// with their respective file names.
26-
// If either file is missing, it returns an os.ErrNotExist error.
27-
// If the files exist, it loads the X.509 key pair from the specified files and sets up a tls.Config.
28-
// Parameters:
29-
// * tlsPath: The directory path where the TLS certificate ("cert.pem") and key ("key.pem") files are located.
30-
// Returns:
31-
// * A tls.Config structure configured with the provided certificate and key.
32-
// * An error if the certificate or key file does not exist, or if loading the key pair fails.
33-
func TLS(tlsPath string) (*tls.Config, error) {
34-
certPath := filepath.Join(tlsPath, cert)
35-
keyPath := filepath.Join(tlsPath, key)
36-
exist := utils.Exists(certPath) && utils.Exists(keyPath)
37-
if !exist {
38-
return nil, os.ErrNotExist
39-
}
40-
41-
cfg := EmptyTLSConfig()
42-
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
43-
if err != nil {
44-
return nil, err
45-
}
46-
cfg.Certificates = append(cfg.Certificates, cert)
47-
return cfg, nil
48-
}
49-
5023
type AuthToken struct {
5124
Token string `json:"x-token"`
5225
}

nodebuilder/state/core.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,7 @@ func coreAccessor(
3434
error,
3535
) {
3636
if corecfg.TLSEnabled {
37-
tlsCfg, err := core.TLS(corecfg.TLSPath)
38-
switch {
39-
case err == nil:
40-
case errors.Is(err, os.ErrNotExist):
41-
// set an empty config if path is empty under `TLSEnabled=true`
42-
tlsCfg = core.EmptyTLSConfig()
43-
default:
44-
return nil, nil, nil, err
45-
}
46-
37+
tlsCfg := core.EmptyTLSConfig()
4738
xtoken, err := core.XToken(corecfg.XTokenPath)
4839
if err != nil && !errors.Is(err, os.ErrNotExist) {
4940
return nil, nil, nil, err

0 commit comments

Comments
 (0)