Skip to content

Commit a852fc0

Browse files
committed
Added flag to skip ssl certificate validation
1 parent 2ecd9f3 commit a852fc0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

connection.go

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

33
import (
4+
"crypto/tls"
45
"encoding/hex"
56
"fmt"
67
"net/http"
@@ -17,11 +18,17 @@ type session struct {
1718
errChan chan error
1819
}
1920

20-
func connect(url, origin string, rlConf *readline.Config) error {
21+
func connect(url, origin string, rlConf *readline.Config, allowInsecure bool) error {
2122
headers := make(http.Header)
2223
headers.Add("Origin", origin)
2324

24-
ws, _, err := websocket.DefaultDialer.Dial(url, headers)
25+
dialer := websocket.Dialer{
26+
Proxy: http.ProxyFromEnvironment,
27+
TLSClientConfig:&tls.Config{
28+
InsecureSkipVerify: allowInsecure,
29+
},
30+
}
31+
ws, _, err := dialer.Dial(url, headers)
2532
if err != nil {
2633
return err
2734
}

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const Version = "0.2.1"
1717
var options struct {
1818
origin string
1919
printVersion bool
20+
insecure bool
2021
}
2122

2223
func main() {
@@ -27,6 +28,7 @@ func main() {
2728
}
2829
rootCmd.Flags().StringVarP(&options.origin, "origin", "o", "", "websocket origin")
2930
rootCmd.Flags().BoolVarP(&options.printVersion, "version", "v", false, "print version")
31+
rootCmd.Flags().BoolVarP(&options.insecure, "insecure", "k", false, "skip ssl certificate check")
3032

3133
rootCmd.Execute()
3234
}
@@ -70,7 +72,7 @@ func root(cmd *cobra.Command, args []string) {
7072
err = connect(dest.String(), origin, &readline.Config{
7173
Prompt: "> ",
7274
HistoryFile: historyFile,
73-
})
75+
}, options.insecure)
7476
if err != nil {
7577
fmt.Fprintln(os.Stderr, err)
7678
if err != io.EOF && err != readline.ErrInterrupt {

0 commit comments

Comments
 (0)