From 8a3aa59272ca847418bc3da63011087203f05f60 Mon Sep 17 00:00:00 2001 From: Tomy Guichard Date: Sat, 3 Jun 2023 11:12:39 +0200 Subject: [PATCH] crash on certificate verification error --- main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 1d58e79..98b7aca 100644 --- a/main.go +++ b/main.go @@ -134,6 +134,19 @@ func getHTTPClient() (*http.Client, error) { }, nil } +func isFatalError(err error) bool { + if errors.Is(err, livebox.ErrInvalidPassword) { + return true + } + + var certError *tls.CertificateVerificationError + if errors.As(err, &certError) { + return true + } + + return false +} + func main() { pollingFrequency := flag.Uint("polling-frequency", defaultPollingFrequency, "Polling frequency") listen := flag.String("listen", ":8080", "Listening address") @@ -192,7 +205,7 @@ func main() { go func() { for { if err := pollers.Poll(ctx); err != nil { - if errors.Is(err, livebox.ErrInvalidPassword) { + if isFatalError(err) { log.Fatal(err) }