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

promtail: add support for TLS/mTLS in syslog receiver #3907

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

johanfleury
Copy link
Contributor

@johanfleury johanfleury commented Jun 25, 2021

What this PR does / why we need it:

Add support for TLS and mTLS in promtail's syslog receiver.

Which issue(s) this PR fixes:

Fixes #3898

Special notes for your reviewer:

Go is not my main language (and I don’t really like it) so there might be some coding-style issue or some bad patterns.

I successfully tested this change using rsyslog and I got the following results:

  • TLS disabled on both sides: works as before
  • TLS enabled on both sides: works as before (with TCP sessions being encrypted)
  • TLS enabled but client sends plain text messages: fails with level=warn ts=2021-06-25T17:34:09.985034229Z caller=syslogtarget.go:207 msg="error initializing syslog stream" err="tls: first record does not look like a TLS handshake"
  • TLS enabled on both sides, with client certificate verification: works as before (with TCP sessions being encrypted)
  • TLS enabled on both sides, with client certificate verification, but client doesn’t send a certificate: fails with level=warn ts=2021-06-25T17:28:22.787523967Z caller=syslogtarget.go:207 msg="error initializing syslog stream" err="tls: client didn't provide a certificate"

Checklist:

  • Documentation added
  • Tests updated

@CLAassistant
Copy link

CLAassistant commented Jun 25, 2021

CLA assistant check
All committers have signed the CLA.

@@ -91,15 +94,58 @@ func (t *SyslogTarget) run() error {
if err != nil {
return fmt.Errorf("error setting up syslog target %w", err)
}

tlsEnabled := len(t.config.TLSConfig.CertFile) > 0 || len(t.config.TLSConfig.CertFile) > 0 || len(t.config.TLSConfig.CAFile) > 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is the best way to check if tls_config is set.


t.openConnections.Add(1)
go t.acceptConnections()

return nil
}

func newTLSConfig(certFile string, keyFile string, caFile string) (*tls.Config, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@johanfleury johanfleury force-pushed the feature/promtail-syslog-tls branch from 0329e14 to 7b16ffc Compare June 25, 2021 22:36
@johanfleury johanfleury force-pushed the feature/promtail-syslog-tls branch from 7b16ffc to f926c1d Compare June 27, 2021 17:58
@johanfleury johanfleury marked this pull request as ready for review June 27, 2021 17:59
@johanfleury johanfleury force-pushed the feature/promtail-syslog-tls branch 2 times, most recently from b7848c3 to 1ff6b8e Compare June 27, 2021 21:11
Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

Spelling correction is needed in the Docs file. Otherwise, the docs portion of the PR looks good to me.

@johanfleury johanfleury force-pushed the feature/promtail-syslog-tls branch from 1ff6b8e to cd52cf5 Compare July 3, 2021 16:25
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@cyriltovena
Copy link
Contributor

@KMiller-Grafana I'll need your approval to merge this one please, thanks !

Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

Thank you for the doc change. Docs LGTM now.

@stale
Copy link

stale bot commented Aug 21, 2021

This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale A stale issue or PR that will automatically be closed. label Aug 21, 2021
@johanfleury
Copy link
Contributor Author

Can we merge this if everybody’s happy with it?

@stale stale bot removed the stale A stale issue or PR that will automatically be closed. label Aug 21, 2021
@stale
Copy link

stale bot commented Sep 21, 2021

Hi! This issue has been automatically marked as stale because it has not had any
activity in the past 30 days.

We use a stalebot among other tools to help manage the state of issues in this project.
A stalebot can be very useful in closing issues in a number of cases; the most common
is closing issues or PRs where the original reporter has not responded.

Stalebots are also emotionless and cruel and can close issues which are still very relevant.

If this issue is important to you, please add a comment to keep it open. More importantly, please add a thumbs-up to the original issue entry.

We regularly sort for closed issues which have a stale label sorted by thumbs up.

We may also:

  • Mark issues as revivable if we think it's a valid issue but isn't something we are likely
    to prioritize in the future (the issue will still remain closed).
  • Add a keepalive label to silence the stalebot if the issue is very common/popular/important.

We are doing our best to respond, organize, and prioritize all issues but it can be a challenging task,
our sincere apologies if you find yourself at the mercy of the stalebot.

@stale stale bot added the stale A stale issue or PR that will automatically be closed. label Sep 21, 2021
@johanfleury
Copy link
Contributor Author

These bots are awful.

@stale stale bot removed the stale A stale issue or PR that will automatically be closed. label Sep 22, 2021
@cyriltovena cyriltovena merged commit 9b0f61d into grafana:main Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

promtail: add support for (m)TLS in syslog receiver
4 participants