Skip to content

Commit

Permalink
config: add possibility to specify tls as bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz committed May 22, 2022
1 parent 4fbec9a commit 08acc7c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kafka/config_tls.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package kafka

import "errors"

// TLSConfig to connect to Kafka via TLS
type TLSConfig struct {
Enabled bool `koanf:"enabled"`
CaFilepath string `koanf:"caFilepath"`
CertFilepath string `koanf:"certFilepath"`
KeyFilepath string `koanf:"keyFilepath"`
Ca []byte
Cert []byte
Key []byte
Passphrase string `koanf:"passphrase"`
InsecureSkipTLSVerify bool `koanf:"insecureSkipTlsVerify"`
}
Expand All @@ -15,5 +20,9 @@ func (c *TLSConfig) SetDefaults() {
}

func (c *TLSConfig) Validate() error {
if (len(c.CaFilepath) > 0 || len(c.CertFilepath) > 0 || len(c.KeyFilepath) > 0) &&
(len(c.Ca) > 0 || len(c.Cert) > 0 || len(c.Key) > 0) {
return errors.New("if caFilepath or certFilepath or keyFilepath is specified, ca, cert, key must be empty")
}
return nil
}

0 comments on commit 08acc7c

Please sign in to comment.