mirror of https://github.com/gophish/gophish
Adjusting SMTP TLS config to use just the hostname instead of the hostname+port when validating certificates. Fixes #1709
parent
c553d7d925
commit
947bb4ccba
|
@ -101,6 +101,7 @@ func (s *SMTP) GetDialer() (mailer.Dialer, error) {
|
||||||
if len(hp) < 2 {
|
if len(hp) < 2 {
|
||||||
hp = append(hp, "25")
|
hp = append(hp, "25")
|
||||||
}
|
}
|
||||||
|
host := hp[0]
|
||||||
// Any issues should have been caught in validation, but we'll
|
// Any issues should have been caught in validation, but we'll
|
||||||
// double check here.
|
// double check here.
|
||||||
port, err := strconv.Atoi(hp[1])
|
port, err := strconv.Atoi(hp[1])
|
||||||
|
@ -108,9 +109,9 @@ func (s *SMTP) GetDialer() (mailer.Dialer, error) {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
d := gomail.NewDialer(hp[0], port, s.Username, s.Password)
|
d := gomail.NewDialer(host, port, s.Username, s.Password)
|
||||||
d.TLSConfig = &tls.Config{
|
d.TLSConfig = &tls.Config{
|
||||||
ServerName: s.Host,
|
ServerName: host,
|
||||||
InsecureSkipVerify: s.IgnoreCertErrors,
|
InsecureSkipVerify: s.IgnoreCertErrors,
|
||||||
}
|
}
|
||||||
hostname, err := os.Hostname()
|
hostname, err := os.Hostname()
|
||||||
|
|
|
@ -73,7 +73,7 @@ func (s *ModelsSuite) TestSMTPGetDialer(ch *check.C) {
|
||||||
dialer := d.(*Dialer).Dialer
|
dialer := d.(*Dialer).Dialer
|
||||||
ch.Assert(dialer.Host, check.Equals, host)
|
ch.Assert(dialer.Host, check.Equals, host)
|
||||||
ch.Assert(dialer.Port, check.Equals, port)
|
ch.Assert(dialer.Port, check.Equals, port)
|
||||||
ch.Assert(dialer.TLSConfig.ServerName, check.Equals, smtp.Host)
|
ch.Assert(dialer.TLSConfig.ServerName, check.Equals, host)
|
||||||
ch.Assert(dialer.TLSConfig.InsecureSkipVerify, check.Equals, smtp.IgnoreCertErrors)
|
ch.Assert(dialer.TLSConfig.InsecureSkipVerify, check.Equals, smtp.IgnoreCertErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue