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

security: Verify SSL certificates #69

Merged
merged 6 commits into from
Apr 14, 2017
Merged

security: Verify SSL certificates #69

merged 6 commits into from
Apr 14, 2017

Conversation

Catharz
Copy link
Contributor

@Catharz Catharz commented Jan 15, 2016

Verifying SSL host against the certificate provided.

Certificate host expiry, etc is checked only as a manual step after connection. It is not an automatic action in OpenSSL. This enables that check.

This means that:

  • self signed certs will not work without specifying the SSL context
  • hosts with a cert for "my-evil-domain.com" will fail to connect if their host name is "my-real-company.com"

Without these checks, all SSL connections are vulnerable to man in the middle attacks.

@Catharz
Copy link
Contributor Author

Catharz commented Jan 15, 2016

Note: Master is failing to build at the moment (due to Ruby 2.3 on Travis).

@dwbutler
Copy link
Owner

👍

This is a Good Thing, but extremely likely to break existing setups. I think it would make sense to make this opt-in, with a warning that it will become the default in the future.

Also adding a deprecation warning for when the SSL context
has not been provided.
@Catharz
Copy link
Contributor Author

Catharz commented Jan 18, 2016

Made the SSL context configurable (and defaulting to none).
But if the SSL context is not provided, it will output a deprecation warning.

@glaszig
Copy link
Contributor

glaszig commented Apr 24, 2016

can we please have this merged? i just discovered, to my surprise, that the tcp connector doesn't even do anything with the certificate i give it. it just opens a dumb ssl socket.

@dwbutler
Copy link
Owner

Sorry, there has been a lot going on and I've been out of action for a while. But I'm reviewing the open pull requests and issues and plan to address them soon.

@dwbutler
Copy link
Owner

@glaszig You're right, the :ssl_certificate option is completely useless. The user should instead be responsible for passing in their own OpenSSL::SSL::SSLContext, as implemented in this PR. I'll deprecate that option.

@franklouwers
Copy link

Hi,

Any updates on this open issue? Do you stil plan on merging it?

@dwbutler
Copy link
Owner

Getting SSL working correctly is of course very important. However, I think there is more work involved to get it working than is contained in this PR. I haven't been able to find the time to investigate this further, and I don't use SSL over TCP myself.

@glaszig
Copy link
Contributor

glaszig commented Feb 8, 2017

i took the liberty to extend upon @Catharz's work and

  • made #use_ssl? respect whether an SSLContext has been set
  • removed the :use_ssl option because it was not documented and is being duplicated by the documented :ssl_enable
  • have certificate hostnames be verified if the context has its verify_mode set to anything other than OpenSSL::SSL::VERIFY_NONE.

see this diff.

unless i missed something this should complete this pr.

@Catharz i can push these commits to your branch if you'll give me access.

@dwbutler
Copy link
Owner

dwbutler commented Feb 8, 2017

Thanks @glaszig. I'll do some due diligence to make sure there aren't any other steps we're missing. I know there are a few gotchas when using SSL in Ruby.

@glaszig
Copy link
Contributor

glaszig commented Feb 8, 2017

oh btw, if you'd just provide an :ssl_certificate, it'll create a simple context with that certificate for you and use that. so this dysfunctional but documented option will just work.

@glaszig
Copy link
Contributor

glaszig commented Feb 12, 2017

interesting and related: ruby/openssl#8
i think we should do a similar thing and not hijack VERIFY_PEER mode as i did. will adjust.

@dwbutler
Copy link
Owner

After some research, the gotchas I was concerned about are mainly in older versions of Ruby. Modern versions of Ruby seem to do the correct thing.

@Catharz @glaszig I'll pull your commits into a new branch and do some merging/cleanup. Thanks for the hard work on this!

@dwbutler dwbutler mentioned this pull request Feb 15, 2017
@glaszig
Copy link
Contributor

glaszig commented Feb 15, 2017

i have one thing left to do. will pr later.

@dwbutler
Copy link
Owner

@glaszig Let me know when it's ready. I can pull it into #114

@glaszig
Copy link
Contributor

glaszig commented Mar 1, 2017

@dwbutler done. refactored the tcp device a little bit and improved hostname verification documentation.

@dwbutler
Copy link
Owner

dwbutler commented Mar 4, 2017

@glaszig Thanks, I reviewed your latest changes and they look correct. I've pulled them into #114. This should be ready to go out soon.

@dwbutler dwbutler merged commit 7a28d90 into dwbutler:master Apr 14, 2017
@dwbutler
Copy link
Owner

Fix released in 0.23.0. Sorry again for the long lead time on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants