1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-04 17:27:02 +00:00

smtp-check: Add a -skip_tls_check flag

This patch adds a -skip_tls_check flag, so smtp-check can still be used
from places where outgoing SMTP connections are blocked.
This commit is contained in:
Alberto Bertogli
2017-01-04 13:36:28 -03:00
parent 6479138c57
commit 700539876b

View File

@@ -17,6 +17,8 @@ import (
var (
port = flag.String("port", "smtp",
"port to use for connecting to the MX servers")
skipTLSCheck = flag.Bool("skip_tls_check", false,
"skip TLS check (useful if connections are blocked)")
)
func main() {
@@ -56,27 +58,32 @@ func main() {
}
}
c, err := smtp.Dial(mx.Host + ":" + *port)
if err != nil {
log.Fatal(err)
}
if *skipTLSCheck {
log.Printf("TLS check skipped")
} else {
c, err := smtp.Dial(mx.Host + ":" + *port)
if err != nil {
log.Fatal(err)
}
config := &tls.Config{
// Expect the server to have a certificate valid for the MX
// we're connecting to.
ServerName: mx.Host,
}
err = c.StartTLS(config)
if err != nil {
log.Fatalf("TLS error: %v", err)
}
config := &tls.Config{
// Expect the server to have a certificate valid for the MX
// we're connecting to.
ServerName: mx.Host,
}
err = c.StartTLS(config)
if err != nil {
log.Fatalf("TLS error: %v", err)
}
cstate, _ := c.TLSConnectionState()
log.Printf("TLS OK: %s - %s", tlsconst.VersionName(cstate.Version),
tlsconst.CipherSuiteName(cstate.CipherSuite))
cstate, _ := c.TLSConnectionState()
log.Printf("TLS OK: %s - %s", tlsconst.VersionName(cstate.Version),
tlsconst.CipherSuiteName(cstate.CipherSuite))
c.Close()
}
log.Printf("")
c.Close()
}
log.Printf("=== Success")