From b75bd4d6c5371473b8ed15e57fd4a7515364fcf7 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sun, 24 Dec 2023 19:03:40 +0000 Subject: [PATCH] Crash on SSL cert/key error, describe issue in log if serving ssl/tls fails, the cert/key files are checked to see if they are accessible, and any errors logged. --- main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 3d96872..090260d 100644 --- a/main.go +++ b/main.go @@ -557,7 +557,16 @@ func start(asDaemon, firstCall bool) { cert := app.config.Section("advanced").Key("tls_cert").MustString("") key := app.config.Section("advanced").Key("tls_key").MustString("") if err := SRV.ListenAndServeTLS(cert, key); err != nil { - app.err.Printf("Failure serving: %s", err) + filesToCheck := []string{cert, key} + fileNames := []string{"Certificate", "Key"} + for i, v := range filesToCheck { + _, err := os.Stat(v) + if err != nil { + app.err.Printf("SSL/TLS %s: %v\n", fileNames[i], err) + } + } + + app.err.Fatalf("Failure serving with SSL/TLS: %s", err) } } else { if err := SRV.ListenAndServe(); err != nil {