From 61ce4d2de91598caa8b27d698e62ba6deacd3e62 Mon Sep 17 00:00:00 2001 From: zaigie Date: Sun, 4 Feb 2024 08:17:33 +0800 Subject: [PATCH] fix(#91): try to fix TLS error --- main.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 0036962..f546d2e 100644 --- a/main.go +++ b/main.go @@ -85,17 +85,8 @@ func main() { go func() { if viper.GetBool("web.tls") { - certFile, err := os.ReadFile(viper.GetString("web.cert_path")) - if err != nil { - panic("Failed to read cert file") - } - keyFile, err := os.ReadFile(viper.GetString("web.key_path")) - if err != nil { - panic("Failed to read key file") - } - - if err := router.RunTLS(fmt.Sprintf(":%d", viper.GetInt("web.port")), string(certFile), string(keyFile)); err != nil { - logger.Errorf("Server exited with error: %v\n", err) + if err := router.RunTLS(fmt.Sprintf(":%d", viper.GetInt("web.port")), viper.GetString("web.cert_path"), viper.GetString("web.key_path")); err != nil { + logger.Errorf("Server exited with TLS error: %v\n", err) } } else { if err := router.Run(fmt.Sprintf(":%d", viper.GetInt("web.port"))); err != nil {