-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add TLS support to socket_writer and socket_listener plugins #4021
Conversation
internal/internal.go
Outdated
// 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( |
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.
Just leave this as GetTLSConfig for now.
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.
Done.
## Enable and require client certificate authentication. | ||
# ssl_client_auth = false | ||
## CAs used to verify client certificates. | ||
# ssl_ca = ["/etc/telegraf/ca.pem"] |
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.
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.
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.
Makes sense -- definitely want to stay consistent. The config now matches those variable names.
e264ea6
to
474e9f3
Compare
I've addressed the comments, however, I still need to investigate why the tests are failing. |
474e9f3
to
7dbc96b
Compare
a1701ba
to
8e1c686
Compare
OK, tests should be sorted now. |
406a096
to
ff3d682
Compare
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() |
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.
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.
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.
I don't see why we need these functions at all...
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.
if you embed net.Listener
directly within unixCloser
so that unixCloser
picks up net.Listener
's methods, then yeah, you shouldn't.
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.
Oh, you mean they aren't needed because they're not even called. yeah... :-)
var ( | ||
c net.Conn | ||
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: 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.
Thanks, I'll get these. |
Fixes #2866.
Required for all PRs: