File tree 4 files changed +3
-57
lines changed
4 files changed +3
-57
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,8 @@ type Config struct {
20
20
RPCPort string
21
21
GRPCPort string
22
22
// 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.
24
24
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
29
25
// XTokenPath specifies the path to the directory with JSON file containing the X-Token for gRPC authentication.
30
26
// The JSON file should have a key-value pair where the key is "x-token" and the value is the authentication token.
31
27
// If left empty, the client will not include the X-Token in its requests.
Original file line number Diff line number Diff line change 12
12
coreRPCFlag = "core.rpc.port"
13
13
coreGRPCFlag = "core.grpc.port"
14
14
coreTLS = "core.tls"
15
- coreTLSPathFlag = "core.tls.path"
16
15
coreXTokenPathFlag = "core.xtoken.path" //nolint:gosec
17
16
)
18
17
@@ -42,15 +41,6 @@ func Flags() *flag.FlagSet {
42
41
false ,
43
42
"Specifies whether TLS is enabled or not. Default: false" ,
44
43
)
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
- )
54
44
flags .String (
55
45
coreXTokenPathFlag ,
56
46
"" ,
@@ -92,11 +82,6 @@ func ParseFlags(
92
82
93
83
if enabled {
94
84
cfg .TLSEnabled = true
95
- if cmd .Flag (coreTLSPathFlag ).Changed {
96
- path := cmd .Flag (coreTLSPathFlag ).Value .String ()
97
- cfg .TLSPath = path
98
- }
99
-
100
85
if cmd .Flag (coreXTokenPathFlag ).Changed {
101
86
path := cmd .Flag (coreXTokenPathFlag ).Value .String ()
102
87
cfg .XTokenPath = path
Original file line number Diff line number Diff line change @@ -20,33 +20,6 @@ func EmptyTLSConfig() *tls.Config {
20
20
return & tls.Config {MinVersion : tls .VersionTLS12 }
21
21
}
22
22
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
-
50
23
type AuthToken struct {
51
24
Token string `json:"x-token"`
52
25
}
Original file line number Diff line number Diff line change @@ -34,16 +34,8 @@ func coreAccessor(
34
34
error ,
35
35
) {
36
36
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 ()
47
39
xtoken , err := core .XToken (corecfg .XTokenPath )
48
40
if err != nil && ! errors .Is (err , os .ErrNotExist ) {
49
41
return nil , nil , nil , err
You can’t perform that action at this time.
0 commit comments