Browse Source

Don't check for valid certificate if the mailserver is local

Brendan Abolivier 7 years ago
parent
commit
31f03fc206
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      src/metrics-alerting/main.go

+ 6
- 0
src/metrics-alerting/main.go View File

1
 package main
1
 package main
2
 
2
 
3
 import (
3
 import (
4
+	"crypto/tls"
4
 	"flag"
5
 	"flag"
5
 
6
 
6
 	"metrics-alerting/alert"
7
 	"metrics-alerting/alert"
51
 				cfg.Mail.SMTP.Host, cfg.Mail.SMTP.Port, cfg.Mail.SMTP.Username,
52
 				cfg.Mail.SMTP.Host, cfg.Mail.SMTP.Port, cfg.Mail.SMTP.Username,
52
 				cfg.Mail.SMTP.Password,
53
 				cfg.Mail.SMTP.Password,
53
 			)
54
 			)
55
+
56
+			// Skip verification for localhost
57
+			if cfg.Mail.SMTP.Host == "127.0.0.1" {
58
+				alerter.Dialer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
59
+			}
54
 		}
60
 		}
55
 
61
 
56
 		if err := process.Process(client, script, alerter); err != nil {
62
 		if err := process.Process(client, script, alerter); err != nil {