Skip to content

Commit d194345

Browse files
authored
NOISSUE - Add WebSocket support to HTTP Proxy (#87)
* remove print line Signed-off-by: Arvindh <arvindh91@gmail.com> * add websocket to http proxy Signed-off-by: Arvindh <arvindh91@gmail.com> * add websocket to http proxy Signed-off-by: Arvindh <arvindh91@gmail.com> * initalized NewOriginChecker Signed-off-by: Arvindh <arvindh91@gmail.com> * add toolchain Signed-off-by: Arvindh <arvindh91@gmail.com> * remove toolchain Signed-off-by: Arvindh <arvindh91@gmail.com> * update the workflow Signed-off-by: Arvindh <arvindh91@gmail.com> * update the workflow Signed-off-by: Arvindh <arvindh91@gmail.com> * go mod tidy Signed-off-by: Arvindh <arvindh91@gmail.com> * convert to interface Signed-off-by: Arvindh <arvindh91@gmail.com> * convert to interface Signed-off-by: Arvindh <arvindh91@gmail.com> * convert to interface Signed-off-by: Arvindh <arvindh91@gmail.com> * format files Signed-off-by: Arvindh <arvindh91@gmail.com> * fix url path Signed-off-by: Arvindh <arvindh91@gmail.com> * fix targetUrl Signed-off-by: Arvindh <arvindh91@gmail.com> * fix mqtt ws Signed-off-by: Arvindh <arvindh91@gmail.com> * add env for listen and target portocol,host,port,path Signed-off-by: Arvindh <arvindh91@gmail.com> * upgrade liniter Signed-off-by: Arvindh <arvindh91@gmail.com> * fix linter errors Signed-off-by: Arvindh <arvindh91@gmail.com> * upgrade liniter Signed-off-by: Arvindh <arvindh91@gmail.com> * fix websocket proxy Signed-off-by: Arvindh <arvindh91@gmail.com> * update getPass func Signed-off-by: Arvindh <arvindh91@gmail.com> * websocket process Signed-off-by: Arvindh <arvindh91@gmail.com> * fix linter errors Signed-off-by: Arvindh <arvindh91@gmail.com> * move checkers to single interface Signed-off-by: Arvindh <arvindh91@gmail.com> * update prefix Signed-off-by: Arvindh <arvindh91@gmail.com> * modified checker Signed-off-by: Arvindh <arvindh91@gmail.com> * consolidate and format function names Signed-off-by: Arvindh <arvindh91@gmail.com> --------- Signed-off-by: Arvindh <arvindh91@gmail.com>
1 parent f76e1c4 commit d194345

File tree

28 files changed

+670
-284
lines changed

28 files changed

+670
-284
lines changed

.env

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,88 @@
1-
MGATE_MQTT_WITHOUT_TLS_ADDRESS=:1884
2-
MGATE_MQTT_WITHOUT_TLS_TARGET=localhost:1883
1+
MGATE_MQTT_WITHOUT_TLS_HOST=localhost
2+
MGATE_MQTT_WITHOUT_TLS_PORT=1884
3+
MGATE_MQTT_WITHOUT_TLS_TARGET_PROTOCOL=mqtt
4+
MGATE_MQTT_WITHOUT_TLS_TARGET_HOST=localhost
5+
MGATE_MQTT_WITHOUT_TLS_TARGET_PORT=1883
36

4-
MGATE_MQTT_WITH_TLS_ADDRESS=:8883
5-
MGATE_MQTT_WITH_TLS_TARGET=localhost:1883
7+
MGATE_MQTT_WITH_TLS_HOST=localhost
8+
MGATE_MQTT_WITH_TLS_PORT=8883
9+
MGATE_MQTT_WITH_TLS_TARGET_PROTOCOL=mqtt
10+
MGATE_MQTT_WITH_TLS_TARGET_HOST=localhost
11+
MGATE_MQTT_WITH_TLS_TARGET_PORT=1883
612
MGATE_MQTT_WITH_TLS_CERT_FILE=ssl/certs/server.crt
713
MGATE_MQTT_WITH_TLS_KEY_FILE=ssl/certs/server.key
814
MGATE_MQTT_WITH_TLS_SERVER_CA_FILE=ssl/certs/ca.crt
915

10-
MGATE_MQTT_WITH_MTLS_ADDRESS=:8884
11-
MGATE_MQTT_WITH_MTLS_TARGET=localhost:1883
16+
MGATE_MQTT_WITH_MTLS_HOST=localhost
17+
MGATE_MQTT_WITH_MTLS_PORT=8884
18+
MGATE_MQTT_WITH_MTLS_TARGET_PROTOCOL=mqtt
19+
MGATE_MQTT_WITH_MTLS_TARGET_HOST=localhost
20+
MGATE_MQTT_WITH_MTLS_TARGET_PORT=1883
1221
MGATE_MQTT_WITH_MTLS_CERT_FILE=ssl/certs/server.crt
1322
MGATE_MQTT_WITH_MTLS_KEY_FILE=ssl/certs/server.key
1423
MGATE_MQTT_WITH_MTLS_SERVER_CA_FILE=ssl/certs/ca.crt
1524
MGATE_MQTT_WITH_MTLS_CLIENT_CA_FILE=ssl/certs/ca.crt
1625
MGATE_MQTT_WITH_MTLS_CERT_VERIFICATION_METHODS=ocsp
1726
MGATE_MQTT_WITH_MTLS_OCSP_RESPONDER_URL=http://localhost:8080/ocsp
1827

19-
MGATE_MQTT_WS_WITHOUT_TLS_ADDRESS=:8083
20-
MGATE_MQTT_WS_WITHOUT_TLS_TARGET=ws://localhost:8000/
28+
MGATE_MQTT_WS_WITHOUT_TLS_HOST=localhost
29+
MGATE_MQTT_WS_WITHOUT_TLS_PORT=8083
30+
MGATE_MQTT_WS_WITHOUT_TLS_PATH_PREFIX=/mgate-ws
31+
MGATE_MQTT_WS_WITHOUT_TLS_TARGET_PROTOCOL=ws
32+
MGATE_MQTT_WS_WITHOUT_TLS_TARGET_HOST=localhost
33+
MGATE_MQTT_WS_WITHOUT_TLS_TARGET_PORT=8000
34+
MGATE_MQTT_WS_WITHOUT_TLS_TARGET_PATH=
2135

22-
MGATE_MQTT_WS_WITH_TLS_ADDRESS=:8084
23-
MGATE_MQTT_WS_WITH_TLS_TARGET=ws://localhost:8000/
36+
MGATE_MQTT_WS_WITH_TLS_HOST=localhost
37+
MGATE_MQTT_WS_WITH_TLS_PORT=8084
38+
MGATE_MQTT_WS_WITH_TLS_PATH_PREFIX=/mgate-ws
39+
MGATE_MQTT_WS_WITH_TLS_TARGET_PROTOCOL=ws
40+
MGATE_MQTT_WS_WITH_TLS_TARGET_HOST=localhost
41+
MGATE_MQTT_WS_WITH_TLS_TARGET_PORT=8000
42+
MGATE_MQTT_WS_WITH_TLS_TARGET_PATH=
2443
MGATE_MQTT_WS_WITH_TLS_CERT_FILE=ssl/certs/server.crt
2544
MGATE_MQTT_WS_WITH_TLS_KEY_FILE=ssl/certs/server.key
2645
MGATE_MQTT_WS_WITH_TLS_SERVER_CA_FILE=ssl/certs/ca.crt
2746

28-
MGATE_MQTT_WS_WITH_MTLS_ADDRESS=:8085
29-
MGATE_MQTT_WS_WITH_MTLS_PATH_PREFIX=/mqtt
30-
MGATE_MQTT_WS_WITH_MTLS_TARGET=ws://localhost:8000/
47+
MGATE_MQTT_WS_WITH_MTLS_HOST=localhost
48+
MGATE_MQTT_WS_WITH_MTLS_PORT=8085
49+
MGATE_MQTT_WS_WITH_MTLS_PATH_PREFIX=/mgate-ws
50+
MGATE_MQTT_WS_WITH_MTLS_TARGET_PROTOCOL=ws
51+
MGATE_MQTT_WS_WITH_MTLS_TARGET_HOST=localhost
52+
MGATE_MQTT_WS_WITH_MTLS_TARGET_PORT=8000
53+
MGATE_MQTT_WS_WITH_MTLS_TARGET_PATH=
3154
MGATE_MQTT_WS_WITH_MTLS_CERT_FILE=ssl/certs/server.crt
3255
MGATE_MQTT_WS_WITH_MTLS_KEY_FILE=ssl/certs/server.key
3356
MGATE_MQTT_WS_WITH_MTLS_SERVER_CA_FILE=ssl/certs/ca.crt
3457
MGATE_MQTT_WS_WITH_MTLS_CLIENT_CA_FILE=ssl/certs/ca.crt
3558
MGATE_MQTT_WS_WITH_MTLS_CERT_VERIFICATION_METHODS=ocsp
3659
MGATE_MQTT_WS_WITH_MTLS_OCSP_RESPONDER_URL=http://localhost:8080/ocsp
3760

38-
MGATE_HTTP_WITHOUT_TLS_ADDRESS=:8086
39-
MGATE_HTTP_WITHOUT_TLS_PATH_PREFIX=/messages
40-
MGATE_HTTP_WITHOUT_TLS_TARGET=http://localhost:8888/
61+
MGATE_HTTP_WITHOUT_TLS_PORT=8086
62+
MGATE_HTTP_WITHOUT_TLS_PATH_PREFIX=/mgate-http
63+
MGATE_HTTP_WITHOUT_TLS_TARGET_PROTOCOL=http
64+
MGATE_HTTP_WITHOUT_TLS_TARGET_HOST=localhost
65+
MGATE_HTTP_WITHOUT_TLS_TARGET_PORT=8888
66+
MGATE_HTTP_WITHOUT_TLS_TARGET_PATH=/messages
4167

42-
MGATE_HTTP_WITH_TLS_ADDRESS=:8087
43-
MGATE_HTTP_WITH_TLS_PATH_PREFIX=/messages
68+
69+
MGATE_HTTP_WITH_TLS_PORT=8087
70+
MGATE_HTTP_WITH_TLS_PATH_PREFIX=/mgate-http
71+
MGATE_HTTP_WITH_TLS_TARGET_PROTOCOL=http
72+
MGATE_HTTP_WITH_TLS_TARGET_HOST=localhost
73+
MGATE_HTTP_WITH_TLS_TARGET_PORT=8888
74+
MGATE_HTTP_WITH_TLS_TARGET_PATH=/messages
4475
MGATE_HTTP_WITH_TLS_TARGET=http://localhost:8888/
4576
MGATE_HTTP_WITH_TLS_CERT_FILE=ssl/certs/server.crt
4677
MGATE_HTTP_WITH_TLS_KEY_FILE=ssl/certs/server.key
4778
MGATE_HTTP_WITH_TLS_SERVER_CA_FILE=ssl/certs/ca.crt
4879

49-
MGATE_HTTP_WITH_MTLS_ADDRESS=:8088
50-
MGATE_HTTP_WITH_MTLS_PATH_PREFIX=/messages
80+
MGATE_HTTP_WITH_MTLS_PORT=8088
81+
MGATE_HTTP_WITH_MTLS_PATH_PREFIX=/mgate-http
82+
MGATE_HTTP_WITH_MTLS_TARGET_PROTOCOL=http
83+
MGATE_HTTP_WITH_MTLS_TARGET_HOST=localhost
84+
MGATE_HTTP_WITH_MTLS_TARGET_PORT=8888
85+
MGATE_HTTP_WITH_MTLS_TARGET_PATH=/messages
5186
MGATE_HTTP_WITH_MTLS_TARGET=http://localhost:8888/
5287
MGATE_HTTP_WITH_MTLS_CERT_FILE=ssl/certs/server.crt
5388
MGATE_HTTP_WITH_MTLS_KEY_FILE=ssl/certs/server.key

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ jobs:
2323
- name: Setup Go
2424
uses: actions/setup-go@v4
2525
with:
26-
go-version: 1.21.x
26+
go-version: 1.22.x
2727
cache-dependency-path: "go.sum"
2828

2929
- name: golangci-lint
30-
uses: golangci/golangci-lint-action@v6
30+
uses: golangci/golangci-lint-action@v7
3131
with:
32-
version: v1.61.0
32+
version: v2.0.2
3333
args: --config .golangci.yml
3434

3535
- name: Build Binaries

.golangci.yml

Lines changed: 75 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,91 @@
1-
# Copyright (c) Abstract Machines
2-
# SPDX-License-Identifier: Apache-2.0
3-
4-
run:
5-
timeout: 10m
6-
7-
issues:
8-
max-issues-per-linter: 100
9-
max-same-issues: 100
10-
11-
linters-settings:
12-
gocritic:
13-
enabled-checks:
14-
- importShadow
15-
- httpNoBody
16-
- paramTypeCombine
17-
- emptyStringTest
18-
- builtinShadow
19-
- exposedSyncMutex
20-
disabled-checks:
21-
- appendAssign
22-
enabled-tags:
23-
- diagnostic
24-
disabled-tags:
25-
- performance
26-
- style
27-
- experimental
28-
- opinionated
29-
misspell:
30-
ignore-words:
31-
- "mosquitto"
32-
stylecheck:
33-
checks: ["-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022"]
34-
goheader:
35-
template: |-
36-
Copyright (c) Abstract Machines
37-
SPDX-License-Identifier: Apache-2.0
38-
1+
version: "2"
392
linters:
40-
disable-all: true
3+
default: none
414
enable:
42-
- gocritic
43-
- gosimple
44-
- errcheck
45-
- govet
46-
- unused
47-
- goconst
48-
- godot
49-
- godox
50-
- ineffassign
51-
- misspell
52-
- stylecheck
53-
- whitespace
54-
- gci
55-
- gofmt
56-
- goimports
57-
- loggercheck
58-
- goheader
595
- asasalint
606
- asciicheck
617
- bidichk
8+
- copyloopvar
629
- decorder
6310
- dogsled
11+
- dupword
12+
- errcheck
6413
- errchkjson
6514
- errname
66-
- copyloopvar
6715
- ginkgolinter
6816
- gocheckcompilerdirectives
69-
- gofumpt
17+
- goconst
18+
- gocritic
19+
- godot
20+
- godox
21+
- goheader
7022
- goprintffuncname
23+
- govet
7124
- importas
25+
- ineffassign
26+
- loggercheck
7227
- makezero
7328
- mirror
29+
- misspell
7430
- nakedret
75-
- dupword
31+
- staticcheck
32+
- unused
33+
- whitespace
34+
settings:
35+
gocritic:
36+
enabled-checks:
37+
- importShadow
38+
- httpNoBody
39+
- paramTypeCombine
40+
- emptyStringTest
41+
- builtinShadow
42+
- exposedSyncMutex
43+
disabled-checks:
44+
- appendAssign
45+
enabled-tags:
46+
- diagnostic
47+
disabled-tags:
48+
- performance
49+
- style
50+
- experimental
51+
- opinionated
52+
goheader:
53+
template: |-
54+
Copyright (c) Abstract Machines
55+
SPDX-License-Identifier: Apache-2.0
56+
misspell:
57+
ignore-rules:
58+
- mosquitto
59+
staticcheck:
60+
checks:
61+
- -ST1000
62+
- -ST1003
63+
- -ST1020
64+
- -ST1021
65+
- -ST1022
66+
exclusions:
67+
generated: lax
68+
presets:
69+
- comments
70+
- common-false-positives
71+
- legacy
72+
- std-error-handling
73+
paths:
74+
- third_party$
75+
- builtin$
76+
- examples$
77+
issues:
78+
max-issues-per-linter: 100
79+
max-same-issues: 100
80+
formatters:
81+
enable:
82+
- gci
83+
- gofmt
84+
- gofumpt
85+
- goimports
86+
exclusions:
87+
generated: lax
88+
paths:
89+
- third_party$
90+
- builtin$
91+
- examples$

cmd/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func main() {
134134
}
135135

136136
// mGate server for HTTP without TLS
137-
httpProxy, err := http.NewProxy(httpConfig, handler, logger)
137+
httpProxy, err := http.NewProxy(httpConfig, handler, logger, []string{}, []string{})
138138
if err != nil {
139139
panic(err)
140140
}
@@ -149,7 +149,7 @@ func main() {
149149
}
150150

151151
// mGate server for HTTP with TLS
152-
httpTLSProxy, err := http.NewProxy(httpTLSConfig, handler, logger)
152+
httpTLSProxy, err := http.NewProxy(httpTLSConfig, handler, logger, []string{}, []string{})
153153
if err != nil {
154154
panic(err)
155155
}
@@ -164,7 +164,7 @@ func main() {
164164
}
165165

166166
// mGate server for HTTP with mTLS
167-
httpMTLSProxy, err := http.NewProxy(httpMTLSConfig, handler, logger)
167+
httpMTLSProxy, err := http.NewProxy(httpMTLSConfig, handler, logger, []string{}, []string{})
168168
if err != nil {
169169
panic(err)
170170
}

config.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ import (
1111
)
1212

1313
type Config struct {
14-
Address string `env:"ADDRESS" envDefault:""`
15-
PathPrefix string `env:"PATH_PREFIX" envDefault:"/"`
16-
Target string `env:"TARGET" envDefault:""`
17-
TLSConfig *tls.Config
14+
Host string `env:"HOST" envDefault:""`
15+
Port string `env:"PORT,required" envDefault:""`
16+
PathPrefix string `env:"PATH_PREFIX" envDefault:""`
17+
TargetHost string `env:"TARGET_HOST,required" envDefault:""`
18+
TargetPort string `env:"TARGET_PORT,required" envDefault:""`
19+
TargetProtocol string `env:"TARGET_PROTOCOL,required" envDefault:""`
20+
TargetPath string `env:"TARGET_PATH" envDefault:""`
21+
TLSConfig *tls.Config
1822
}
1923

2024
func NewConfig(opts env.Options) (Config, error) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Requirements to run scripts
2+
- [Websocat 4.0.0](https://github.com/vi/websocat)
3+
- OpenSSL
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
protocol=wss
3+
host=localhost
4+
port=8088
5+
path="mgate-http/messages/ws"
6+
content="application/json"
7+
message="{\"message\": \"Hello mGate\"}"
8+
invalidPath="invalid_path"
9+
cafile=ssl/certs/ca.crt
10+
certfile=ssl/certs/client.crt
11+
keyfile=ssl/certs/client.key
12+
reovokedcertfile=ssl/certs/client_revoked.crt
13+
reovokedkeyfile=ssl/certs/client_revoked.key
14+
unknowncertfile=ssl/certs/client_unknown.crt
15+
unknownkeyfile=ssl/certs/client_unknown.key
16+
17+
echo "Posting message to ${protocol}://${host}:${port}/${path} with tls, Authorization header, ca & client certificates ${cafile} ${certfile} ${keyfile}..."
18+
echo "${message}" | websocat --binary --ws-c-uri="${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization:TOKEN" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet -CAfile ${cafile} -cert ${certfile} -key ${keyfile}"
19+
20+
21+
echo -e "\nPosting message to ${protocol}://${host}:${port}/${path} with tls, basic authentication ca & client certificates ${cafile} ${certfile} ${keyfile}..."
22+
encoded=$(printf "username:password" | base64)
23+
echo "${message}" | websocat --binary --ws-c-uri="${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization: Basic $encoded" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet -CAfile ${cafile} -cert ${certfile} -key ${keyfile}"
24+
25+
echo -e "\nPosting message to invalid path ${protocol}://${host}:${port}/${path}/${invalidPath} with tls, Authorization header, ca & client certificates ${cafile} ${certfile} ${keyfile}..."
26+
echo "${message}" | websocat --binary --ws-c-uri="${protocol}://${host}:${port}/${invalidPath}" -H "content-type:${content}" -H "Authorization:TOKEN" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet -CAfile ${cafile} -cert ${certfile} -key ${keyfile}"
27+
28+
echo -e "\nPosting message to ${protocol}://${host}:${port}/${path} with tls, Authorization header, ca certificates ${cafile} & reovked client certificate ${reovokedcertfile} ${reovokedkeyfile}..."
29+
echo "${message}" | websocat --binary --ws-c-uri="${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization:TOKEN" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet -CAfile ${cafile} -cert ${reovokedcertfile} -key ${reovokedkeyfile}"
30+
31+
echo -e "\nPosting message to ${protocol}://${host}:${port}/${path} with tls, Authorization header, ca certificates ${cafile} & unknown client certificate ${unknowncertfile} ${unknownkeyfile}..."
32+
echo "${message}" | websocat --binary --ws-c-uri="${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization:TOKEN" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet -CAfile ${cafile} -cert ${unknowncertfile} -key ${unknownkeyfile}"
33+
34+
echo -e "\nPosting message to ${protocol}://${host}:${port}/${path} with tls, Authorization header, ca certificate ${cafile} & without client certificates.."
35+
echo "${message}" | websocat --binary --ws-c-uri="${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization:TOKEN" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet -CAfile ${cafile}"
36+
37+
echo -e "\nPosting message to ${protocol}://${host}:${port}/${path} with tls, Authorization header, & without ca , client certificates.."
38+
echo "${message}" | websocat --binary --ws-c-uri="${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization:TOKEN" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
protocol=wss
3+
host=localhost
4+
port=8087
5+
path="mgate-http/messages/ws"
6+
content="application/json"
7+
message="{\"message\": \"Hello mGate\"}"
8+
invalidPath="invalid_path"
9+
cafile=ssl/certs/ca.crt
10+
certfile=ssl/certs/client.crt
11+
keyfile=ssl/certs/client.key
12+
reovokedcertfile=ssl/certs/client_revoked.crt
13+
reovokedkeyfile=ssl/certs/client_revoked.key
14+
unknowncertfile=ssl/certs/client_unknown.crt
15+
unknownkeyfile=ssl/certs/client_unknown.key
16+
17+
echo "Posting message to ${protocol}://${host}:${port}/${path} with tls, Authorization header, ca certificate ${cafile}..."
18+
# echo "${message}" | websocat -H "content-type:${content}" -H "Authorization:TOKEN" --binary --ws-c-uri="${protocol}://${host}:${port}/${path}" - ws-c:cmd:"openssl s_client -connect ${host}:${port} -quiet -verify_quiet -CAfile ${cafile}"
19+
echo "${message}" | SSL_CERT_FILE="${cafile}" websocat "${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization:TOKEN"
20+
21+
22+
echo -e "\nPosting message to ${protocol}://${host}:${port}/${path} with tls, basic authentication ca certificate ${cafile}...."
23+
encoded=$(printf "username:password" | base64)
24+
echo "${message}" | SSL_CERT_FILE="${cafile}" websocat "${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization: Basic $encoded"
25+
26+
27+
echo -e "\nPosting message to ${protocol}://${host}:${port}/${path} with tls, Authorization header, and without ca certificate.."
28+
echo "${message}" | websocat "${protocol}://${host}:${port}/${path}" -H "content-type:${content}" -H "Authorization: Basic $encoded"
29+

0 commit comments

Comments
 (0)