Server TLS

Start server without TLS by default
This commit is contained in:
8lecramm 2024-04-11 21:36:07 +02:00 committed by GitHub
parent afb29670c8
commit beab244bce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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()