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

Enforcing VERIFY_PEER on the client #5

Merged
merged 4 commits into from
Jul 31, 2015

Conversation

ph
Copy link
Contributor

@ph ph commented Jul 30, 2015

The ruby client did not enforce the validation of the certificate,
opening possible man in the middle attacks on the client. This PR make sure that
the verify_mode is set to VERIFY_PEER and add the certificate to the store
for this specific connection. An integration test was added to validate
this change.

This change makes the ruby client handling of connection closer to the
logstash-forwarder behavior, which does the verify peer per default.

Fixes #4

@ph ph added the bug label Jul 30, 2015
@ph ph force-pushed the fix/clients-should-use-certificate branch from 759fb5f to 593355b Compare July 30, 2015 14:19
@ph
Copy link
Contributor Author

ph commented Jul 30, 2015

Small cleanups in the dependencies and how we specify the files in the gemspec.

The ruby client did not enforce the validation of the certificate,
opening possible man in the middle attacks on the client. This PR make sure that
the `verify_mode` is set to `VERIFY_PEER` and add the certificate to the store
for this specific connection. An integration test was added to validate
this change.

This change makes the ruby client handling of connection closer to the
`logstash-forwarder` behavior, which does the verify peer per default.

Fixes #4
@ph ph force-pushed the fix/clients-should-use-certificate branch from 593355b to ea44add Compare July 30, 2015 14:22
client = Lumberjack::Client.new(:port => port,
:host => host,
:addresses => host,
:ssl_certificate => certificate_file_crt)
Copy link
Member

Choose a reason for hiding this comment

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

no need for a ssl_key parameter on the client side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the client use the public key to encrypt which is available in the certificate and the server use the private key to decrypt it? The ssl_key was never a requirement in the logstash-output-lumberjack. But yes, the LSF has an optional key option in the config, I'll check it more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/elastic/logstash-forwarder/blob/master/publisher1.go#L137

I'll check on the ruby side, I am +1 on having the same behavior, I need to investigate what it's actually do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

we don't currently require a client certificate, it's optional.

@ph
Copy link
Contributor Author

ph commented Jul 30, 2015

Thanks @jsvd for the comment, I'll do a bit more thinking.

@@ -0,0 +1,57 @@
# encoding: utf-8
require "lib/lumberjack/client"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the 'lib/' part here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😞 by myself on that

@jordansissel
Copy link
Contributor

Added some inline comments. Tests pass (bundle exec rspec) once the lib/ part is removed as I commented.

Let's get expected-rejection cases added also (client connects to a server that is not trusted, etc)

@ph
Copy link
Contributor Author

ph commented Jul 30, 2015

@jordansissel I have added another test to cover a not trusted server.
This PR requires a new release of ruby-flores with jordansissel/ruby-flores#3

@ph
Copy link
Contributor Author

ph commented Jul 31, 2015

updated with @jordansissel comments.

@jordansissel
Copy link
Contributor

Tests passing.

jordansissel added a commit that referenced this pull request Jul 31, 2015
@jordansissel jordansissel merged commit b91d393 into master Jul 31, 2015
@ph ph deleted the fix/clients-should-use-certificate branch April 28, 2016 12:51
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.

ssl_certificate never used in Client
3 participants