-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX "PLAIN" auth during notification via smtp-over-tls on port 465 #1591
Conversation
When creating a `NewClient`, pass only the hostname as value for the `host` parameter, instead of `n.conf.Smarthost`, which is hostname port. This is the same as `smtp.Dial` does, which is called in the else-branch. Signed-off-by: Claudio Kressibucher <ckressibucher@graphicworks.ch>
088c20d
to
352b2ae
Compare
Thanks for the PR! A quick look makes me believe that it is correct. Especially when looking at func Dial(addr string) (*Client, error) {
conn, err := net.Dial("tcp", addr)
if err != nil {
return nil, err
}
host, _, _ := net.SplitHostPort(addr)
return NewClient(conn, host)
} |
I don't feel well versed enough in email to understand the implications of this code change. If anyone feels confident about their knowledge and ability to test this, by all means raise a hand. |
👍 for this PR. |
If there would be no ServerName set, the DialWithDialer function in crypto/tls/tls.go:132 sets ServerName to the hostname (which does not include the port number) So what's the reason this PR is not merged yet? ;) |
See the comments above. We were basically waiting for feedback from people testing this PR. Taking into account your report, I'd say 👍 for me. |
@simonpasquier Thanks, that works. I have tested gmail(port 587) and another mail provider (port 465 with ssl), everything goes fine. |
@mxinden @stuartnelson3 this PR looks reasonable to me and seems to fix the original issue. Any problem from your side merging it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help on this @ckressibucher @dirkmb and @chanjarster.
When creating a
NewClient
, pass only the hostnameas value for the
host
parameter, instead ofn.conf.Smarthost
,which is hostname port.
This is the same as
smtp.Dial
does, which is called inthe else-branch.
The value passed as
host
argument toNewClient
islater compared against the
plainAuth.host
value:net/smtp.(*Client).Auth
andnet/smtp.(*plainAuth).Start
(plainAuth is created created here: https://github.com/prometheus/alertmanager/blob/master/notify/impl.go#L245)
In my tests, this fixed the problems described in #980
Note: after this change, the strings which are compared in
https://golang.org/src/net/smtp/auth.go at (
if server.Name != a.host
)are derived from the same config value. I think that is correct, but as it
might affect security, it should be reviewed carefully.