crash on certificate verification error

This commit is contained in:
Tomy Guichard 2023-06-03 11:12:39 +02:00
parent 8215e950e9
commit 8a3aa59272

15
main.go
View file

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