-
Notifications
You must be signed in to change notification settings - Fork 5.7k
add support for SMTP server certificates over STARTTLS #7680
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
add support for SMTP server certificates over STARTTLS #7680
Conversation
@@ -10,7 +10,7 @@ file or network connection. | |||
# Reads metrics from a SSL certificate | |||
[[inputs.x509_cert]] | |||
## List certificate sources | |||
sources = ["/etc/ssl/certs/ssl-cert-snakeoil.pem", "https://example.org:443"] | |||
sources = ["/etc/ssl/certs/ssl-cert-snakeoil.pem", "https://example.org:443", "smtp+starttls://smtp.example.org:587"] |
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.
Rename to smtp per #7679 (comment)
@@ -21,7 +22,7 @@ import ( | |||
|
|||
const sampleConfig = ` | |||
## List certificate sources | |||
sources = ["/etc/ssl/certs/ssl-cert-snakeoil.pem", "tcp://example.org:443"] | |||
sources = ["/etc/ssl/certs/ssl-cert-snakeoil.pem", "https://example.org:443", "smtp+starttls://smtp.example.org:587"] |
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.
smtp://
@@ -100,6 +101,58 @@ func (c *X509Cert) getCert(u *url.URL, timeout time.Duration) ([]*x509.Certifica | |||
|
|||
certs := conn.ConnectionState().PeerCertificates | |||
|
|||
return certs, nil | |||
case "smtp+starttls": | |||
u.Scheme = "smtp+starttls" |
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.
Make a function for the body of the case statement, since now this function is becoming very large.
defer sclient.Text.EndResponse(id) | ||
_, _, err = sclient.Text.ReadResponse(220) | ||
if err != nil { | ||
return nil, fmt.Errorf("did not get 220 after STARTTLS: %s", err.Error()) |
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.
Nit: switch over to the new %w format for wrapping errors
"did not get 220 after STARTTLS: %w", err)
@tryfail any chance you can work on the comments? |
@tryfail any update on this PR? |
Hi, This PR has not been touched in a while and as a result I am going to close it. We are happy to review again once someone picks this back up with the suggested changes and rebased on master. Thanks! |
Required for all PRs:
closes #7679 .
I am not too familiar with the unit test structure for golang and telegraf. Additionally, I did not find a way to create an analogous test to that of the local TLS server.
Currently known limitations: