Skip to content

Commit 164c851

Browse files
committed
feat(agent): validate TLS certificates before enabling TLS for integrations
1 parent 7d31359 commit 164c851

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

agent/modules/configuration.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ func ChangeIntegrationStatus(logTyp string, proto string, isEnabled bool, tlsOpt
6969
// Handle TLS configuration if specified
7070
if len(tlsOptions) > 0 && isEnabled {
7171
if tlsOptions[0] {
72+
if !utils.CheckIfPathExist(config.IntegrationCertPath) || !utils.CheckIfPathExist(config.IntegrationKeyPath) {
73+
return "", fmt.Errorf("TLS certificates not found. Please load certificates first")
74+
}
7275
// Enable TLS
7376
integration.TCP.TLSEnabled = true
7477
mod := GetModule(logTyp)

agent/modules/syslog.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ func (m *SyslogModule) GetPort(proto string) string {
9898
func (m *SyslogModule) EnablePort(proto string, enableTLS bool) error {
9999
switch proto {
100100
case "tcp":
101+
if enableTLS {
102+
if !utils.CheckIfPathExist(config.IntegrationCertPath) || !utils.CheckIfPathExist(config.IntegrationKeyPath) {
103+
return fmt.Errorf("TLS certificates not found. Please load certificates first")
104+
}
105+
}
106+
101107
m.TCPListener.TLSEnabled = enableTLS
102108
go m.enableTCP()
103109
return nil

0 commit comments

Comments
 (0)