Skip to content

Commit

Permalink
added insecure tls option
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeljkoBenovic committed Dec 11, 2022
1 parent 394f7a6 commit 682ca52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions framework/adapters/right/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package webhook

import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -53,8 +54,16 @@ func (a *Adapter) SendToWebhook(dataToSend interface{}) error {
// print request headers in debug log
a.debugHTTPRequestHeaders(req)

// set new http client
client := &http.Client{}
// set new http client with secure or insecure TLS
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
//nolint
InsecureSkipVerify: a.config.TLSInsecure,
},
},
}

// send the request and wait for response
resp, respErr := client.Do(req)
if respErr != nil {
Expand Down
2 changes: 2 additions & 0 deletions framework/types/cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
LogLevel string `yaml:"log-level"`
AMIDebug bool `yaml:"ami_debug"`
AMIDebugFile string `yaml:"ami_debug_file"`
TLSInsecure bool `yaml:"tls_insecure"`

ExportDefaultConfig bool `yaml:"-"`
ConfigFileLocation string `yaml:"-"`
Expand Down Expand Up @@ -59,6 +60,7 @@ func (c *Config) ProcessConfig() error {
flag.StringVar(&c.AMIDebugFile, "ami-debug-file", "", "File to write all AMI events to")

flag.BoolVar(&c.ExportDefaultConfig, "export", false, "Set this flag to export the default config file")
flag.BoolVar(&c.TLSInsecure, "tls-insecure", false, "Use insecure TLS communication, do not check for valid cert")
flag.StringVar(&c.LogLevel, "log-level", "info", "Turn on the debug mode and output everything to console")

flag.Parse()
Expand Down

0 comments on commit 682ca52

Please sign in to comment.