Skip to content

Commit

Permalink
Skip TLS verification in login flow if requested (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental authored Jan 9, 2022
1 parent 30435c5 commit c916448
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion internal/login/login.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package login

import (
"crypto/tls"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -55,14 +56,19 @@ type Client struct {
}

// Init creates a new LoginClient. The session can then be started using StartInteractive.
func Init(log logrus.FieldLogger, userAgent, serverURL string) *Client {
func Init(log logrus.FieldLogger, userAgent, serverURL string, tlsSkipVerify bool) *Client {
return &Client{
log: log,
userAgent: userAgent,
serverURL: serverURL,

client: &http.Client{
Timeout: 30 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: tlsSkipVerify,
},
},
},
sleepFunc: func() { time.Sleep(pollInterval) },
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func main() {
if cfg.ServerURL == "" {
log.Fatalf("Need to specify --server for login.")
}
loginClient := login.Init(log, userAgent, cfg.ServerURL)
loginClient := login.Init(log, userAgent, cfg.ServerURL, cfg.TLSSkipVerify)

log.Infof("Starting interactive login on: %s", cfg.ServerURL)
if err := loginClient.StartInteractive(); err != nil {
Expand Down

0 comments on commit c916448

Please sign in to comment.