From beab244bcecde1d7c95b48c1b96ab2549f880463 Mon Sep 17 00:00:00 2001 From: 8lecramm <89603217+8lecramm@users.noreply.github.com> Date: Thu, 11 Apr 2024 21:36:07 +0200 Subject: [PATCH] Server TLS Start server without TLS by default --- server.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index 5253b2b..4f55b94 100644 --- a/server.go +++ b/server.go @@ -247,12 +247,14 @@ func StartServer() { // certFile = fullchain.pem // keyFile = privkey.pem - // comment the following block to disable TLS + // uncomment the following block to enable TLS; edit cert files first + /* cert, err := tls.LoadX509KeyPair("/etc/letsencrypt/live/mg25ot4aggt8dprv.myfritz.net/fullchain.pem", "/etc/letsencrypt/live/mg25ot4aggt8dprv.myfritz.net/privkey.pem") if err != nil { log.Println(err) os.Exit(2) } + */ mux := http.NewServeMux() mux.HandleFunc("/ws", webSocketHandler) @@ -260,10 +262,10 @@ func StartServer() { srv := nbhttp.NewServer(nbhttp.Config{ Network: "tcp", Handler: mux, - // comment the following 2 lines and uncomment "Addrs" to start server without TLS - AddrsTLS: []string{cfg.Settings.ListenAddress}, - TLSConfig: &tls.Config{Certificates: []tls.Certificate{cert}}, - //Addrs: []string{cfg.Settings.ListenAddress}, + // uncomment the following 2 lines and comment "Addrs" to start server with TLS + //AddrsTLS: []string{cfg.Settings.ListenAddress}, + //TLSConfig: &tls.Config{Certificates: []tls.Certificate{cert}}, + Addrs: []string{cfg.Settings.ListenAddress}, }) err = srv.Start()