Skip to content

Commit 4436a9f

Browse files
committed
remove tlsPath
1 parent 0bb5c62 commit 4436a9f

File tree

4 files changed

+3
-57
lines changed

4 files changed

+3
-57
lines changed

nodebuilder/core/config.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ type Config struct {
2020
RPCPort string
2121
GRPCPort string
2222
// TLSEnabled specifies whether the connection is secure or not.
23-
// PLEASE NOTE: it should be set to true in order to handle TLSPath and/or XTokenPath.
23+
// PLEASE NOTE: it should be set to true in order to handle XTokenPath.
2424
TLSEnabled bool
25-
// TLSPath specifies the directory path where the TLS certificates are stored.
26-
// It should not include file names('cert.pem' and 'key.pem').
27-
// If left empty, the client will be configured for an insecure (non-TLS) connection.
28-
TLSPath string
2925
// XTokenPath specifies the path to the directory with JSON file containing the X-Token for gRPC authentication.
3026
// The JSON file should have a key-value pair where the key is "x-token" and the value is the authentication token.
3127
// 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
@@ -12,7 +12,6 @@ var (
1212
coreRPCFlag = "core.rpc.port"
1313
coreGRPCFlag = "core.grpc.port"
1414
coreTLS = "core.tls"
15-
coreTLSPathFlag = "core.tls.path"
1615
coreXTokenPathFlag = "core.xtoken.path" //nolint:gosec
1716
)
1817

@@ -42,15 +41,6 @@ func Flags() *flag.FlagSet {
4241
false,
4342
"Specifies whether TLS is enabled or not. Default: false",
4443
)
45-
flags.String(
46-
coreTLSPathFlag,
47-
"",
48-
"specifies the directory path where the TLS certificates are stored. "+
49-
"It should not include file names ('cert.pem' and 'key.pem'). "+
50-
"NOTE: the path is parsed only if coreTLS enabled."+
51-
"If left empty, with disabled coreTLS, the client will be configured for "+
52-
"an insecure (non-TLS) connection",
53-
)
5444
flags.String(
5545
coreXTokenPathFlag,
5646
"",
@@ -92,11 +82,6 @@ func ParseFlags(
9282

9383
if enabled {
9484
cfg.TLSEnabled = true
95-
if cmd.Flag(coreTLSPathFlag).Changed {
96-
path := cmd.Flag(coreTLSPathFlag).Value.String()
97-
cfg.TLSPath = path
98-
}
99-
10085
if cmd.Flag(coreXTokenPathFlag).Changed {
10186
path := cmd.Flag(coreXTokenPathFlag).Value.String()
10287
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

+2-10
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,8 @@ 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+
// set an empty config if path is empty under `TLSEnabled=true`
38+
tlsCfg := core.EmptyTLSConfig()
4739
xtoken, err := core.XToken(corecfg.XTokenPath)
4840
if err != nil && !errors.Is(err, os.ErrNotExist) {
4941
return nil, nil, nil, err

0 commit comments

Comments
 (0)