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 server TLS certificate verification #2171

Merged
merged 7 commits into from
Jun 16, 2020

Conversation

takanabe
Copy link
Contributor

@takanabe takanabe commented Jun 3, 2020

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #1986

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2020

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.02%. Comparing base (f04bc99) to head (3a0a390).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2171      +/-   ##
==========================================
- Coverage   62.09%   62.02%   -0.08%     
==========================================
  Files         156      156              
  Lines       12531    12531              
==========================================
- Hits         7781     7772       -9     
- Misses       4143     4148       +5     
- Partials      607      611       +4     

see 3 files with indirect coverage changes

@pull-request-size pull-request-size bot added size/S and removed size/XS labels Jun 3, 2020
@takanabe takanabe marked this pull request as ready for review June 3, 2020 14:31
@takanabe takanabe force-pushed the add_server_tls_verification branch from 7c294c1 to e6f5c43 Compare June 3, 2020 14:38
@@ -210,6 +210,21 @@ Specify a pair of client certificate and private key with `cert` and `key` if a
</match>
```

### server certificate verification
A flag to enable a server certificate verification. By default the `verify_tls` is set to true.
Copy link
Contributor

Choose a reason for hiding this comment

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

"to disable server verification"? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This explanation should be fine. The reason why we introduce this flag is to specify server TLS verification mode. Not for disabling the verification. If we think, "to disable" is better, we need to change the option to no_tls_verify or something.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think your thinking around this patch came off the wrong foot. You seem to have thought that we somehow want to be able to enable server certificate verification. It is enabled by default and we really look for a way to optionally disable it :).

Copy link
Contributor

Choose a reason for hiding this comment

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

So, let's focus on the actual patch first and then adjust the docs, ok?

@pull-request-size pull-request-size bot added size/M and removed size/S labels Jun 4, 2020
@jgehrcke
Copy link
Contributor

jgehrcke commented Jun 4, 2020

Some high level feedback, clarifying the motivation and goal.

According to rdoc, the default value is VERIFY_NONE.

This seems to be veeeery out-of-date documentation (I don't know Ruby, otherwise I would have been a little more motivated to tackle this patch myself). The Internet and open-source software fortunately moved on around 2014 and 2015, switching stdlibs to do certificate verification by default :-) Ruby is no exception, fortunately:

https://github.com/ruby/ruby/blob/ruby_2_7/sample/drb/drbssl_c.rb#L9
https://github.com/ruby/ruby/blob/v2_7_1/lib/rubygems/request.rb#L52

    connection.use_ssl = true
    connection.verify_mode =
      Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER

That is, the default is of course to verify the server certificate when doing HTTPS.

That's how this patch came off the wrong foot I think. As one can also see when comparing the title of #1986 ("add option to disable server certificate verification") and the title of this PR ("Add server TLS certificate verification") --> conflict between core of the issue, and (your previous) goal of this PR.

Really, we need a switch to optionally disable server certificate verification. Convinced?

I keep the current default for this plugin (VERIFY_PEER) but enable developers to turn off the verification with verify_tls = false 07e0def

The current patch isn't doing that! In a working patch we will find a part of the (new) code that sets

verify_mode: OpenSSL::SSL::VERIFY_NONE

but only when verify_tls is set to false :-).

Makes sense?

I'll happily review again, just ping me please.

@takanabe
Copy link
Contributor Author

takanabe commented Jun 4, 2020

Thank you for the comment! I read the links and net/http and you are right. The default value of verify_mode is OpenSSL::SSL::VERIFY_PEER.

I pushed new commit based on your advice 4aadf60. If you are happy to the commit, I will update document as well 📝

@takanabe
Copy link
Contributor Author

@jgehrcke could you review the changes?

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

Can you update the doc now ?

@takanabe takanabe force-pushed the add_server_tls_verification branch from 4aadf60 to e1dac90 Compare June 16, 2020 12:36
@takanabe
Copy link
Contributor Author

@cyriltovena thank you for the review!

I pushed the commit to update document e1dac90

Should I rebase all commits into one commit or will you squash-merge this PR?

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 with one nit.

@cyriltovena cyriltovena merged commit e2a7941 into grafana:master Jun 16, 2020
@takanabe takanabe deleted the add_server_tls_verification branch June 30, 2020 00:45
@jgehrcke
Copy link
Contributor

jgehrcke commented Jul 6, 2020

Thanks again everyone here.

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.

fluent-plugin-grafana-loki: add option to disable server certificate verification
4 participants