Skip to content

Commit fa3e52b

Browse files
Meteoritealfonso-presa
authored andcommitted
add support for skipping tls certificate verification in client-to-server websocket connections
cherry-picked from: #84 credits: https://github.com/Meteorite closes: #34
1 parent f3a8df2 commit fa3e52b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ $ chisel client --help
216216
the chisel server. Authentication can be specified inside the URL.
217217
For example, http://admin:[email protected]:8081
218218
219+
--skip-tls-verification, Don't verify the server's TLS certificate
220+
chain and host name (if TLS is used for transport connections to
221+
server). If set, client accepts any TLS certificate presented by
222+
the server and any host name in that certificate. This influences
223+
only transport https (wss) connections. Chisel server's public key
224+
may be still verified (see --fingerprint) after inner connection
225+
is established.
226+
219227
--hostname, Optionally set the 'Host' header (defaults to the host
220228
defined in the endpoint url).
221229

client/client.go

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

33
import (
44
"context"
5+
"crypto/tls"
56
"fmt"
67
"io"
78
"net"
@@ -26,6 +27,7 @@ type Config struct {
2627
MaxRetryCount int
2728
MaxRetryInterval time.Duration
2829
Server string
30+
SkipTlsVerification bool
2931
HTTPProxy string
3032
Remotes []string
3133
HostHeader string
@@ -199,6 +201,9 @@ func (c *Client) connectionLoop() {
199201
return c.httpProxyURL, nil
200202
}
201203
}
204+
if c.config.SkipTlsVerification {
205+
d.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
206+
}
202207
wsHeaders := http.Header{}
203208
if c.config.HostHeader != "" {
204209
wsHeaders = http.Header{

main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ var clientHelp = `
264264
the chisel server. Authentication can be specified inside the URL.
265265
For example, http://admin:[email protected]:8081
266266
267+
--skip-tls-verification, Don't verify the server's TLS certificate
268+
chain and host name (if TLS is used for transport connections to
269+
server). If set, client accepts any TLS certificate presented by
270+
the server and any host name in that certificate. This influences
271+
only transport https (wss) connections. Chisel server's public key
272+
may be still verified (see --fingerprint) after inner connection
273+
is established.
274+
267275
--hostname, Optionally set the 'Host' header (defaults to the host
268276
found in the server url).
269277
` + commonHelp
@@ -278,6 +286,7 @@ func client(args []string) {
278286
maxRetryCount := flags.Int("max-retry-count", -1, "")
279287
maxRetryInterval := flags.Duration("max-retry-interval", 0, "")
280288
proxy := flags.String("proxy", "", "")
289+
skipTlsVerification := flags.Bool("skip-tls-verification", false, "")
281290
pid := flags.Bool("pid", false, "")
282291
hostname := flags.String("hostname", "", "")
283292
verbose := flags.Bool("v", false, "")
@@ -302,6 +311,7 @@ func client(args []string) {
302311
MaxRetryInterval: *maxRetryInterval,
303312
HTTPProxy: *proxy,
304313
Server: args[0],
314+
SkipTlsVerification: *skipTlsVerification,
305315
Remotes: args[1:],
306316
HostHeader: *hostname,
307317
})

0 commit comments

Comments
 (0)