Skip to content

Commit

Permalink
fix missing Checkcert parameter + wrong logic with its usage
Browse files Browse the repository at this point in the history
Signed-off-by: Issif <issif+github@gadz.org>
  • Loading branch information
Issif authored and poiana committed Jul 20, 2022
1 parent 4aa56d3 commit 3d78ab1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions outputs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func NewClient(outputType string, defaultEndpointURL string, mutualTLSEnabled bo
log.Printf("[ERROR] : %v - %v\n", outputType, err.Error())
return nil, ErrClientCreation
}
return &Client{OutputType: outputType, EndpointURL: endpointURL, MutualTLSEnabled: mutualTLSEnabled, HeaderList: []Header{}, ContentType: DefaultContentType, Config: config, Stats: stats, PromStats: promStats, StatsdClient: statsdClient, DogstatsdClient: dogstatsdClient}, nil
return &Client{OutputType: outputType, EndpointURL: endpointURL, MutualTLSEnabled: mutualTLSEnabled, CheckCert: checkCert, HeaderList: []Header{}, ContentType: DefaultContentType, Config: config, Stats: stats, PromStats: promStats, StatsdClient: statsdClient, DogstatsdClient: dogstatsdClient}, nil
}

// Post sends event (payload) to Output.
Expand Down Expand Up @@ -178,7 +178,7 @@ func (c *Client) Post(payload interface{}) error {
}
} else {
// With MutualTLS enabled, the check cert flag is ignored
if c.CheckCert {
if !c.CheckCert {
// #nosec G402 This is only set as a result of explicit configuration
customTransport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
Expand Down
2 changes: 1 addition & 1 deletion outputs/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestNewClient(t *testing.T) {
stats := &types.Statistics{}
promStats := &types.PromStatistics{}

testClientOutput := Client{OutputType: "test", EndpointURL: u, MutualTLSEnabled: false, HeaderList: []Header{}, ContentType: "application/json; charset=utf-8", Config: config, Stats: stats, PromStats: promStats}
testClientOutput := Client{OutputType: "test", EndpointURL: u, MutualTLSEnabled: false, CheckCert: true, HeaderList: []Header{}, ContentType: "application/json; charset=utf-8", Config: config, Stats: stats, PromStats: promStats}
_, err := NewClient("test", "localhost/%*$¨^!/:;", false, true, config, stats, promStats, nil, nil)
require.NotNil(t, err)

Expand Down

0 comments on commit 3d78ab1

Please sign in to comment.