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

🎚 Use rustls for https directly, for more control #100

Merged
merged 3 commits into from
Dec 1, 2021
Merged

Conversation

aturon
Copy link
Contributor

@aturon aturon commented Dec 1, 2021

Previous work (#75) moved Viceroy to using rustls for TLS, with some good benefits. However, the hyper_rustls library bakes in a fair amount of TLS configuration that we need to control more directly.

Since hyper_rustls is a very thin library, and since we already need our own Hyper connector for other reasons, I opted to just use rustls directly within Viceroy, for maximum clarity/control. The main downside is that there's a bit of boilerplate around TCP/TLS streams.

Along the way, this PR also refactors the CLI backend health checks to use the Viceroy library, rather than connecting in its own way, which will help ensure we keep those in sync.

I've confirmed that this PR:

Fixes #91
Fixes #96

The CLI performs backend health checks on startup. Previously it was setting up its own TLS connector, but this commit changes it to use the same connector we use in viceroy-lib (now called `BackendConnector`) to ensure consistency and centralize any connector changes.
Rather than using hyper_rustls as before, this approach gives us more direct control over how TLS is connected and configured, including things like SNI and ALPN.
cratelyn
cratelyn previously approved these changes Dec 1, 2021
Copy link
Contributor

@cratelyn cratelyn left a comment

Choose a reason for hiding this comment

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

this is wonderful, wonderful work @aturon.

great job ✨ ✔️

/// The TLS configuration for this execution.
///
/// Populated prior to guest execution, and never modified.
pub(crate) tls_config: Arc<rustls::ClientConfig>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub(crate) tls_config: Arc<rustls::ClientConfig>,
tls_config: Arc<rustls::ClientConfig>,

because we mention that this is never modified in the comment, perhaps we can remove the pub(crate) visibility here, to help enforce that?

that leaves the tls_config accessor below as the sole interface through which other modules can acquire a reference to this 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

(this is one of those "take it or leave it" comments)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh good catch, i was following the pattern of the other read-only items. they should all be using accessors rather than pub(crate), so I'll add a commit to do that 👍

@aturon
Copy link
Contributor Author

aturon commented Dec 1, 2021

@cratelyn pushed up a commit tidying up the privacy for read-only session fields.

Copy link
Contributor

@cratelyn cratelyn left a comment

Choose a reason for hiding this comment

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

🎉 ✨ 😻

@cratelyn
Copy link
Contributor

cratelyn commented Dec 1, 2021

@cratelyn pushed up a commit tidying up the privacy for read-only session fields.

@aturon thanks for fixing up the other fields while you were doing this! 🙂

@aturon aturon merged commit 0afb688 into main Dec 1, 2021
@aturon aturon deleted the aturon/no-alpn branch December 1, 2021 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants