Skip to content

Commit

Permalink
Fix mTLS configuration parsing. (stripe#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavdugar-stripe authored Feb 9, 2023
1 parent c6ae106 commit 0da19f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ func (s *Server) Start() {

// Initialize a gRPC connection for forwarding
var err error
if s.Config.Tls != nil {
if s.Config.Tls != nil && s.Config.Tls.CaFile != "" && s.Config.Tls.CertFile != "" && s.Config.Tls.KeyFile != "" {
var tlsConfig *tls.Config
tlsConfig, err = s.Config.Tls.GetTlsConfig()
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions util/tls/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ tls:
assert.Error(t, err)
}

func TestGetTlsConfigEmpty(t *testing.T) {
yamlFile := []byte(`---
tls:
`)
data := yamlStruct{}
err := yaml.Unmarshal(yamlFile, &data)
assert.NoError(t, err)
assert.Nil(t, data.Tls)
}

func TestGetTlsConfigUnset(t *testing.T) {
data := yamlStruct{}
err := yaml.Unmarshal([]byte{}, &data)
Expand Down

0 comments on commit 0da19f0

Please sign in to comment.