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

chore(networking)!: Move all TLS support over to openssl #1986

Merged
merged 12 commits into from Mar 6, 2020
Merged

Conversation

bruceg
Copy link
Member

@bruceg bruceg commented Mar 4, 2020

This is incomplete, as several error paths remain incomplete.

There is one possible user-visible configuration change. At this point, the verify_hostname setting is non-functional due to a difference (at least in my understanding) of how openssl handles verification as compared to native_tls. I am still investigating and may need to port some code over to accommodate the differences.

Closes #1402
Closes #1929

Bruce Guenter added 4 commits March 4, 2020 10:14
Signed-off-by: Bruce Guenter <bruce@timber.io>
Signed-off-by: Bruce Guenter <bruce@timber.io>
Signed-off-by: Bruce Guenter <bruce@timber.io>
Signed-off-by: Bruce Guenter <bruce@timber.io>
@bruceg bruceg added type: tech debt A code change that does not add user value. domain: security Anything related to security domain: networking Anything related to Vector's networking labels Mar 4, 2020
@bruceg bruceg requested a review from LucioFranco March 4, 2020 22:42
Bruce Guenter added 2 commits March 4, 2020 16:51
Signed-off-by: Bruce Guenter <bruce@timber.io>
Signed-off-by: Bruce Guenter <bruce@timber.io>
@LucioFranco
Copy link
Contributor

@bruceg for the verify stuff it looks like SslConnectorBuilder::set_verify and https://docs.rs/openssl/0.10.28/openssl/ssl/struct.SslVerifyMode.html setting this to NONE should be the same as setting the dangerous setting for native tls. In the end native-tls maps to openssl so we should be able to find in the code what it does and port that.

Otherwise, this is looking really good, once you have the error paths in I can give this the final look over. Great work!

@bruceg
Copy link
Member Author

bruceg commented Mar 5, 2020

I've found the separate settings for verifying the hostname vs the certificate, but it will require a little bit of type reworking (the functions are in separate types). However, I've been hamstrung by a separate verification bug -- even with using SslVerifyMode::NONE, the send_lines_tls function in test_utils.rs is failing due to "unable to get local issuer certificate", which shouldn't be happening if verification is turned off.

@bruceg
Copy link
Member Author

bruceg commented Mar 5, 2020

The issue lies in the acceptor side's certificate verification setting, which actually points to a bit of a problem with our configuration defaults. We default verify_certificate to true, which can actually have two different meanings for the acceptor side that native-tls didn't expose:

  1. If the connector presents a certificate, verify it, but succeed otherwise. This is the existing behavior.
  2. Require a certificate from the connector, fail if it isn't present, and verify it.

If we have a single verify_certificate setting, I think 2 makes more sense for the acceptor, since you can't verify what isn't presented and clients don't normally present a certificate. However, that becomes a breaking change to our defaults. I could add another setting for that, but it becomes a little redundant.

It was requiring certificate verification, which has changed behavior
now.

Signed-off-by: Bruce Guenter <bruce@timber.io>
@bruceg bruceg marked this pull request as ready for review March 5, 2020 16:44
Copy link
Member

@lukesteensen lukesteensen left a comment

Choose a reason for hiding this comment

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

The bits I'm familiar with look reasonable 👍

Copy link
Contributor

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM, just one non blocking question.

src/tls.rs Show resolved Hide resolved
This ends up *disabling* `verify_hostname` for all of the sinks that
directly or indirectly use the
`hyper_openssl::HttpsConnector::with_connector` method.

Signed-off-by: Bruce Guenter <bruce@timber.io>
@bruceg bruceg requested a review from binarylogic as a code owner March 5, 2020 20:56
@binarylogic
Copy link
Contributor

If this is a breaking change we should add a ! to the title.

@bruceg bruceg changed the title chore(networking): Move all TLS support over to openssl chore(networking)!: Move all TLS support over to openssl Mar 5, 2020
Bruce Guenter added 3 commits March 5, 2020 16:04
Signed-off-by: Bruce Guenter <bruce@timber.io>
Signed-off-by: Bruce Guenter <bruce@timber.io>
This restores the verification behavior prior to this change series.

This effectively reverts e165c9a "Fix
test `sources::socket::test::tcp_with_tls`"

Signed-off-by: Bruce Guenter <bruce@timber.io>
@bruceg
Copy link
Member Author

bruceg commented Mar 5, 2020

Ok, I think the churn is done. I'd appreciate a re-review of the late commits, as there are some behavioural changes.

@@ -128,15 +128,15 @@ pub struct IdentityStore(Vec<u8>, String);
impl TlsSettings {
pub fn from_config(
config: &Option<TlsConfig>,
require_ident: bool,
for_server: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that this setting is for a server? aka if we are a server we set this to true?

Also looks like we are not updating any other rust files where before this boolean meant something else, just want to make sure that is correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, setting this to true is for servers. I renamed it because it controls both requiring an identity (certificate + key) in the configuration as well as changing the defaults for certificate verification. The only users of from_config that would set this to true are the server sources, so no changes to them were required.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for the future, can we add a comment what these params mean since I feel like people stumbling across this in the future might be confused.

Copy link
Member Author

Choose a reason for hiding this comment

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

Absolutely, I was already thinking this as you were asking.

Signed-off-by: Bruce Guenter <bruce@timber.io>
Copy link
Contributor

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

Thanks for getting this done @bruceg! I know working with openssl is never fun but this should really ensure we have some good consistency with all our sinks/sources/transforms.

@bruceg bruceg merged commit 9f793a7 into master Mar 6, 2020
@bruceg bruceg deleted the only-openssl branch March 6, 2020 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: networking Anything related to Vector's networking domain: security Anything related to security type: tech debt A code change that does not add user value.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move TLS support over to tokio_openssl Ensure all sinks use hyper-openssl instead of hyper-tls
4 participants