Skip to content

Commit a85718b

Browse files
committed
Added support for self signed/insecure SSL certs by introducing the --insecure flag
1 parent 19b87bf commit a85718b

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

pkg/cmd/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -94,6 +94,7 @@ func init() {
9494
rootCmd.PersistentFlags().StringVar(&Config.ProfilesFile, "config", "", "config file (default is $HOME/.config/hookdeck/config.toml)")
9595
rootCmd.PersistentFlags().StringVar(&Config.Profile.DeviceName, "device-name", "", "device name")
9696
rootCmd.PersistentFlags().StringVar(&Config.LogLevel, "log-level", "info", "log level (debug, info, warn, error)")
97+
rootCmd.PersistentFlags().BoolVar(&Config.Insecure, "insecure", false, "Allow invalid TLS certificates")
9798
rootCmd.PersistentFlags().StringVarP(&Config.Profile.ProfileName, "project-name", "p", "default", "the project name to read from for config")
9899

99100
// Hidden configuration flags, useful for dev/debugging

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Config struct {
3737
ProfilesFile string
3838
APIBaseURL string
3939
DashboardBaseURL string
40+
Insecure bool
4041
}
4142

4243
// GetConfigFolder retrieves the folder where the profiles file is stored

pkg/listen/listen.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -114,6 +114,7 @@ func Listen(URL *url.URL, source_alias string, connection_query string, flags Fl
114114
NoWSS: flags.NoWSS,
115115
URL: URL,
116116
Log: log.StandardLogger(),
117+
Insecure: config.Insecure,
117118
}, source, connections)
118119

119120
err = p.Run(context.Background())

pkg/proxy/proxy.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package proxy
22

33
import (
44
"context"
5+
"crypto/tls"
56
"encoding/json"
67
"errors"
78
"fmt"
@@ -44,7 +45,8 @@ type Config struct {
4445
PrintJSON bool
4546
Log *log.Logger
4647
// Force use of unencrypted ws:// protocol instead of wss://
47-
NoWSS bool
48+
NoWSS bool
49+
Insecure bool
4850
}
4951

5052
// A Proxy opens a websocket connection with Hookdeck, listens for incoming
@@ -246,13 +248,18 @@ func (p *Proxy) processAttempt(msg websocket.IncomingMessage) {
246248
fmt.Println(webhookEvent.Body.Request.DataString)
247249
} else {
248250
url := p.cfg.URL.Scheme + "://" + p.cfg.URL.Host + p.cfg.URL.Path + webhookEvent.Body.Path
251+
tr := &http.Transport{
252+
TLSClientConfig: &tls.Config{InsecureSkipVerify: p.cfg.Insecure},
253+
}
249254

250255
timeout := webhookEvent.Body.Request.Timeout
251256
if timeout == 0 {
252257
timeout = 1000 * 30
253258
}
259+
254260
client := &http.Client{
255-
Timeout: time.Duration(timeout) * time.Millisecond,
261+
Timeout: time.Duration(timeout) * time.Millisecond,
262+
Transport: tr,
256263
}
257264

258265
req, err := http.NewRequest(webhookEvent.Body.Request.Method, url, nil)

0 commit comments

Comments
 (0)