Skip to content
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 TLS support to socket_writer and socket_listener plugins #4021

Merged
merged 9 commits into from
Apr 18, 2018

Conversation

bobmshannon
Copy link
Contributor

Fixes #2866.

Required for all PRs:

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

// for use with a client.
// The full path to each file must be provided.
// Returns a nil pointer if all files are blank and InsecureSkipVerify=false.
func GetClientTLSConfig(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leave this as GetTLSConfig for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

## Enable and require client certificate authentication.
# ssl_client_auth = false
## CAs used to verify client certificates.
# ssl_ca = ["/etc/telegraf/ca.pem"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a little bit of prior art on the server side: #3191, I would prefer if we use the same variable names, but let me know if you think that is a problem. The biggest difference is that client_auth is enabled automatically if there are cacerts specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense -- definitely want to stay consistent. The config now matches those variable names.

@bobmshannon bobmshannon force-pushed the bs/socket_security branch 5 times, most recently from e264ea6 to 474e9f3 Compare April 17, 2018 03:52
@bobmshannon
Copy link
Contributor Author

I've addressed the comments, however, I still need to investigate why the tests are failing.

@bobmshannon
Copy link
Contributor Author

OK, tests should be sorted now.

@danielnelson danielnelson added this to the 1.7.0 milestone Apr 18, 2018
@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Apr 18, 2018
@danielnelson danielnelson merged commit 0b4f4b0 into influxdata:master Apr 18, 2018
@danielnelson
Copy link
Contributor

Thanks!

@@ -313,6 +338,14 @@ func (uc unixCloser) Close() error {
return err
}

func (uc unixCloser) Accept() (net.Conn, error) {
return uc.closer.(net.Listener).Accept()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're assuming that uc.closer is always going to be a net.Listener, you can avoid the type assertion by redefining uc.closer to be a net.Listener.
This is good practice anyway as then you get compile time verification that you never assign anything other than a net.Listener to uc.closer, as if you do otherwise this code will panic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we need these functions at all...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you embed net.Listener directly within unixCloser so that unixCloser picks up net.Listener's methods, then yeah, you shouldn't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you mean they aren't needed because they're not even called. yeah... :-)

var (
c net.Conn
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: it's idiomatic go to declare variables right before they're used, not at the top of the function.
Also err doesn't need to be declared at all. It'll get declared on line 83.

@danielnelson
Copy link
Contributor

Thanks, I'll get these.

@danielnelson
Copy link
Contributor

1486ae2

This pull request was closed.
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.

3 participants