diff options
author | Alex Auvolat <alex@adnab.me> | 2021-03-08 17:22:46 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-09-28 17:41:18 +0200 |
commit | bc40bed6e561c034654d757f2514e9e24be388ea (patch) | |
tree | 63d650ba1800bdcb6e183240550f456fea70bc21 | |
parent | 54d085f7f3f0a8f6da83cc599c19c593b1412dc3 (diff) | |
download | alps-bc40bed6e561c034654d757f2514e9e24be388ea.tar.gz alps-bc40bed6e561c034654d757f2514e9e24be388ea.zip |
Implement "skip TLS verification" as command line argument
-rw-r--r-- | cmd/alps/main.go | 1 | ||||
-rw-r--r-- | imap.go | 3 | ||||
-rw-r--r-- | server.go | 11 | ||||
-rw-r--r-- | smtp.go | 3 |
4 files changed, 11 insertions, 7 deletions
diff --git a/cmd/alps/main.go b/cmd/alps/main.go index 5a00957..b38ac59 100644 --- a/cmd/alps/main.go +++ b/cmd/alps/main.go @@ -34,6 +34,7 @@ func main() { flag.StringVar(&options.Theme, "theme", "", "default theme") flag.StringVar(&addr, "addr", ":1323", "listening address") flag.BoolVar(&options.Debug, "debug", false, "enable debug logs") + flag.BoolVar(&options.SkipTlsVerification, "skiptlsverification", false, "skip TLS hostname verification") flag.StringVar(&loginKey, "login-key", "", "Fernet key for login persistence") flag.Usage = func() { @@ -1,6 +1,7 @@ package alps import ( + "crypto/tls" "fmt" "github.com/emersion/go-imap" @@ -16,7 +17,7 @@ func (s *Server) dialIMAP() (*imapclient.Client, error) { var c *imapclient.Client var err error if s.imap.tls { - c, err = imapclient.DialTLS(s.imap.host, nil) + c, err = imapclient.DialTLS(s.imap.host, &tls.Config{InsecureSkipVerify: s.Options.SkipTlsVerification}) if err != nil { return nil, fmt.Errorf("failed to connect to IMAPS server: %v", err) } @@ -365,11 +365,12 @@ func handleUnauthenticated(next echo.HandlerFunc, ctx *Context) error { } type Options struct { - Upstreams []string - Theme string - ThemesPath string - Debug bool - LoginKey *fernet.Key + Upstreams []string + Theme string + ThemesPath string + Debug bool + SkipTlsVerification bool + LoginKey *fernet.Key } // New creates a new server. @@ -1,6 +1,7 @@ package alps import ( + "crypto/tls" "fmt" "github.com/emersion/go-smtp" @@ -14,7 +15,7 @@ func (s *Server) dialSMTP() (*smtp.Client, error) { var c *smtp.Client var err error if s.smtp.tls { - c, err = smtp.DialTLS(s.smtp.host, nil) + c, err = smtp.DialTLS(s.smtp.host, &tls.Config{InsecureSkipVerify: s.Options.SkipTlsVerification}) if err != nil { return nil, fmt.Errorf("failed to connect to SMTPS server: %v", err) } |