Skip to content

Commit

Permalink
fix: unmarshal ca, privateKey, cert as string instead of byte slice (#…
Browse files Browse the repository at this point in the history
…193)

fixes #191
  • Loading branch information
TheMeier authored Mar 28, 2023
1 parent 7367a4a commit 89c2276
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ zk-multiple-kafka-multiple
.idea

config
kminion
6 changes: 3 additions & 3 deletions kafka/client_config_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func NewKgoConfig(cfg Config, logger *zap.Logger) ([]kgo.Opt, error) {
if cfg.TLS.Enabled {
// Root CA
if cfg.TLS.CaFilepath != "" || len(cfg.TLS.Ca) > 0 {
ca := cfg.TLS.Ca
ca := []byte(cfg.TLS.Ca)
if cfg.TLS.CaFilepath != "" {
caBytes, err := ioutil.ReadFile(cfg.TLS.CaFilepath)
if err != nil {
Expand All @@ -135,8 +135,8 @@ func NewKgoConfig(cfg Config, logger *zap.Logger) ([]kgo.Opt, error) {
hasCertFile := cfg.TLS.CertFilepath != "" || len(cfg.TLS.Cert) > 0
hasKeyFile := cfg.TLS.KeyFilepath != "" || len(cfg.TLS.Key) > 0
if hasCertFile || hasKeyFile {
cert := cfg.TLS.Cert
privateKey := cfg.TLS.Key
cert := []byte(cfg.TLS.Cert)
privateKey := []byte(cfg.TLS.Key)
// 1. Read certificates
if cfg.TLS.CertFilepath != "" {
certBytes, err := ioutil.ReadFile(cfg.TLS.CertFilepath)
Expand Down
6 changes: 3 additions & 3 deletions kafka/config_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ type TLSConfig struct {
CaFilepath string `koanf:"caFilepath"`
CertFilepath string `koanf:"certFilepath"`
KeyFilepath string `koanf:"keyFilepath"`
Ca []byte `koanf:"ca"`
Cert []byte `koanf:"cert"`
Key []byte `koanf:"key"`
Ca string `koanf:"ca"`
Cert string `koanf:"cert"`
Key string `koanf:"key"`
Passphrase string `koanf:"passphrase"`
InsecureSkipTLSVerify bool `koanf:"insecureSkipTlsVerify"`
}
Expand Down

0 comments on commit 89c2276

Please sign in to comment.