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 {
|
||||
hp = append(hp, "25")
|
||||
}
|
||||
host := hp[0]
|
||||
// Any issues should have been caught in validation, but we'll
|
||||
// double check here.
|
||||
port, err := strconv.Atoi(hp[1])
|
||||
|
@ -108,9 +109,9 @@ func (s *SMTP) GetDialer() (mailer.Dialer, error) {
|
|||
log.Error(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{
|
||||
ServerName: s.Host,
|
||||
ServerName: host,
|
||||
InsecureSkipVerify: s.IgnoreCertErrors,
|
||||
}
|
||||
hostname, err := os.Hostname()
|
||||
|
|
|
@ -73,7 +73,7 @@ func (s *ModelsSuite) TestSMTPGetDialer(ch *check.C) {
|
|||
dialer := d.(*Dialer).Dialer
|
||||
ch.Assert(dialer.Host, check.Equals, host)
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue