Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunil Sayyaparaju authored and Sunil Sayyaparaju committed Jun 19, 2024
2 parents 45dd484 + d1574b4 commit 2e0a1cb
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ make release-docker-multi-arch
# Root CA to validate client certificates (for mutual TLS)
root_ca = ""
# Golang - refer documentation https://pkg.go.dev/crypto/tls#pkg-constants of golang CipherSuites for TLS >=1.2 (both supported and Insecure)
# a comma separated TLS Cipher suites to use, example: TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384
# NOTE: Cipher configuration is support only till TLS1.2 verison and not possible in TLS1.3
tls_cipher_suites = ""
# Passphrase for encrypted key_file. Supports below formats,
# 1. Passphrase directly - "<passphrase>"
# 2. Passphrase via file - "file:<file-that-contains-passphrase>"
Expand All @@ -374,7 +379,8 @@ make release-docker-multi-arch
basic_auth_username=""
basic_auth_password=""
```

- NOTE: Minimum TLS version is 1.2, tls_cipher_suites can be configured only upto TLS1.2

- Use users' allowlist and blocklist configuration to filter out the users for which the statistics are to be fetched. The user statistics are available in Aerospike 5.6+. To fetch user statistics, the authenticated user must have `user-admin` privilege.
```toml
[Aerospike]
Expand Down
5 changes: 5 additions & 0 deletions configs/ape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
# Root CA to validate client certificates (for mutual TLS)
root_ca = ""

# a comma separated TLS Cipher suites to use, example: TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384
# Golang - refer documentation https://pkg.go.dev/crypto/tls#pkg-constants of golang CipherSuites for TLS >=1.2 (both supported and Insecure)
# NOTE: Cipher configuration is support only till TLS1.2 verison and not possible in TLS1.3
tls_cipher_suites = ""

# Passphrase for encrypted key_file. Supports below formats,
# 1. Passphrase directly - "<passphrase>"
# 2. Passphrase via file - "file:<file-that-contains-passphrase>"
Expand Down
1 change: 1 addition & 0 deletions configs/gauge_stats_list.toml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ namespace_gauge_stats =[
"data_used_pct",
"index_mounts_used_pct",
"index_used_bytes",
"indexes_memory_used_pct",
"set_index_used_bytes",
"sindex_mounts_used_pct",
"sindex_used_bytes",
Expand Down
46 changes: 46 additions & 0 deletions internal/pkg/commons/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,49 @@ func HandleSignals() {
}
}()
}

// Utility method fetch the support Cipher in the Golang/OS combination
//
// from configures ciphers in ape.toml, filters the matched and valid-ciphers
// Ciphers are configurable only upto TLS 1.2 version
func GetConfiguredCipherSuiteIds() []uint16 {
supportedCipherSuites := loadCipherSuitesList()
log.Trace("Supported CipherSuites ", supportedCipherSuites)

cipherSuiteIds := []uint16{}

if len(strings.Trim(config.Cfg.Agent.TlsCipherSuites, " ")) > 0 {
return cipherSuiteIds
}

log.Trace("Configured Cipher Suite Names : ", config.Cfg.Agent.TlsCipherSuites)
configuredCipherSuites := strings.Split(config.Cfg.Agent.TlsCipherSuites, ",")

for _, cipherName := range configuredCipherSuites {
cipherName = strings.Trim(cipherName, " ")

if len(cipherName) == 0 {
continue
}

id, ok := supportedCipherSuites[strings.ToUpper(cipherName)]
if !ok {
log.Error("Unrecognized TLS Cipher Name, ignoring : ", cipherName)
} else {
cipherSuiteIds = append(cipherSuiteIds, id)
}

}

return cipherSuiteIds
}

func loadCipherSuitesList() map[string]uint16 {
supportedCipherSuites := make(map[string]uint16)
// supported secure cipher suites
for _, suite := range tls.CipherSuites() {
supportedCipherSuites[suite.Name] = suite.ID
}

return supportedCipherSuites
}
1 change: 1 addition & 0 deletions internal/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
KeyFile string `toml:"key_file"`
RootCA string `toml:"root_ca"`
KeyFilePassphrase string `toml:"key_file_passphrase"`
TlsCipherSuites string `toml:"tls_cipher_suites"`

BasicAuthUsername string `toml:"basic_auth_username"`
BasicAuthPassword string `toml:"basic_auth_password"`
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/executors/prometheus_httplistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ func initExporterTLS() *tls.Config {
log.Fatal(err)
}

// Golang docs -- https://pkg.go.dev/crypto/tls#section-documentation
tlsConfig := &tls.Config{
Certificates: serverPool,
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
CipherSuites: commons.GetConfiguredCipherSuiteIds(),
PreferServerCipherSuites: true,
InsecureSkipVerify: false,
}
Expand Down

0 comments on commit 2e0a1cb

Please sign in to comment.