Skip to content

Commit 1448469

Browse files
authored
feat(tls): enable configurable tls cipher suites and support legacy ciphers (#1384)
1 parent ef4e937 commit 1448469

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

conf/input.http_response/http_response.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,27 @@ targets = [
6969
# tls_key = "/etc/categraf/key.pem"
7070
## Use TLS but skip chain & host verification
7171
# insecure_skip_verify = false
72+
# tls_min_version = "1.2"
73+
# tls_max_version = "1.3"
74+
# tls_cipher_suites = [
75+
# "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
76+
# "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
77+
# "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
78+
# "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
79+
# "TLS_AES_128_GCM_SHA256",
80+
# "TLS_AES_256_GCM_SHA384",
81+
# "TLS_CHACHA20_POLY1305_SHA256",
82+
# "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
83+
# "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
84+
# "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
85+
# "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
86+
# "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
87+
# "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
88+
# "TLS_RSA_WITH_AES_128_GCM_SHA256",
89+
# "TLS_RSA_WITH_AES_256_GCM_SHA384",
90+
# "TLS_RSA_WITH_AES_128_CBC_SHA",
91+
# "TLS_RSA_WITH_AES_256_CBC_SHA",
92+
# "TLS_RSA_WITH_AES_128_CBC_SHA256",
93+
# "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
94+
# "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
95+
# ]

pkg/tls/config.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ import (
1212

1313
// ClientConfig represents the standard client TLS config.
1414
type ClientConfig struct {
15-
UseTLS bool `toml:"use_tls"`
16-
TLSCA string `toml:"tls_ca"`
17-
TLSCert string `toml:"tls_cert"`
18-
TLSKey string `toml:"tls_key"`
19-
TLSKeyPwd string `toml:"tls_key_pwd"`
20-
InsecureSkipVerify bool `toml:"insecure_skip_verify"`
21-
ServerName string `toml:"tls_server_name"`
22-
TLSMinVersion string `toml:"tls_min_version"`
23-
TLSMaxVersion string `toml:"tls_max_version"`
15+
UseTLS bool `toml:"use_tls"`
16+
TLSCA string `toml:"tls_ca"`
17+
TLSCert string `toml:"tls_cert"`
18+
TLSKey string `toml:"tls_key"`
19+
TLSKeyPwd string `toml:"tls_key_pwd"`
20+
InsecureSkipVerify bool `toml:"insecure_skip_verify" json:"insecure_skip_verify"`
21+
ServerName string `toml:"tls_server_name" json:"tls_server_name"`
22+
TLSMinVersion string `toml:"tls_min_version"`
23+
TLSMaxVersion string `toml:"tls_max_version"`
24+
TLSCipherSuites []string `toml:"tls_cipher_suites"`
2425
}
2526

2627
// ServerConfig represents the standard server TLS config.
@@ -62,6 +63,15 @@ func (c *ClientConfig) TLSConfig() (*tls.Config, error) {
6263
}
6364
}
6465

66+
if len(c.TLSCipherSuites) != 0 {
67+
cipherSuites, err := ParseCiphers(c.TLSCipherSuites)
68+
if err != nil {
69+
return nil, fmt.Errorf(
70+
"could not parse client cipher suites %s: %v", strings.Join(c.TLSCipherSuites, ","), err)
71+
}
72+
tlsConfig.CipherSuites = cipherSuites
73+
}
74+
6575
if c.ServerName != "" {
6676
tlsConfig.ServerName = c.ServerName
6777
}

0 commit comments

Comments
 (0)