File tree 4 files changed +2
-57
lines changed
4 files changed +2
-57
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,8 @@ type Config struct {
18
18
IP string
19
19
Port string
20
20
// 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.
22
22
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
27
23
// XTokenPath specifies the path to the directory with JSON file containing the X-Token for gRPC authentication.
28
24
// The JSON file should have a key-value pair where the key is "x-token" and the value is the authentication token.
29
25
// If left empty, the client will not include the X-Token in its requests.
Original file line number Diff line number Diff line change 11
11
coreFlag = "core.ip"
12
12
coreGRPCFlag = "core.grpc.port"
13
13
coreTLS = "core.tls"
14
- coreTLSPathFlag = "core.tls.path"
15
14
coreXTokenPathFlag = "core.xtoken.path" //nolint:gosec
16
15
)
17
16
@@ -36,15 +35,6 @@ func Flags() *flag.FlagSet {
36
35
false ,
37
36
"Specifies whether TLS is enabled or not. Default: false" ,
38
37
)
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
- )
48
38
flags .String (
49
39
coreXTokenPathFlag ,
50
40
"" ,
@@ -81,11 +71,6 @@ func ParseFlags(
81
71
82
72
if enabled {
83
73
cfg .TLSEnabled = true
84
- if cmd .Flag (coreTLSPathFlag ).Changed {
85
- path := cmd .Flag (coreTLSPathFlag ).Value .String ()
86
- cfg .TLSPath = path
87
- }
88
-
89
74
if cmd .Flag (coreXTokenPathFlag ).Changed {
90
75
path := cmd .Flag (coreXTokenPathFlag ).Value .String ()
91
76
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,7 @@ 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
+ tlsCfg := core .EmptyTLSConfig ()
47
38
xtoken , err := core .XToken (corecfg .XTokenPath )
48
39
if err != nil && ! errors .Is (err , os .ErrNotExist ) {
49
40
return nil , nil , nil , err
You can’t perform that action at this time.
0 commit comments