Skip to content

Conversation

tryfail
Copy link

@tryfail tryfail commented Jun 14, 2020

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

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:

  • slower execution for mail tarpits with slow replies like OpenBSD's spamd. Still works fine with the default timeout
  • cannot define ehlo/helo values (similar situation prior to adding SNI support in this plugin)
    • could be incompatible with some SMTP server non-default configurations which may demand a specific EHLO parameter that is different than the FQDN. So far, compatible with outlook, google, servers I care for

@@ -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"]
Copy link
Contributor

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"]
Copy link
Contributor

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"
Copy link
Contributor

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())
Copy link
Contributor

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)

@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jun 18, 2020
@srebhan
Copy link
Member

srebhan commented Oct 20, 2021

@tryfail any chance you can work on the comments?

@srebhan srebhan self-assigned this Oct 20, 2021
@srebhan
Copy link
Member

srebhan commented Nov 30, 2021

@tryfail any update on this PR?

@srebhan srebhan added the waiting for response waiting for response from contributor label Nov 30, 2021
@powersj
Copy link
Contributor

powersj commented Jan 24, 2022

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!

@powersj powersj closed this Jan 24, 2022
@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x509_cert: add support for SMTP certificates over STARTTLS
4 participants