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 rustls support #390

Merged
merged 15 commits into from
Dec 17, 2018
Merged

Add rustls support #390

merged 15 commits into from
Dec 17, 2018

Conversation

quininer
Copy link
Contributor

close #378

Copy link
Owner

@seanmonstar seanmonstar 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 a fantastic start!

Since crate features are additive, we'll need to support if both default-tls and rustls-tls are enabled.

src/error.rs Outdated
@@ -293,6 +293,8 @@ pub(crate) enum Kind {
UrlBadScheme,
#[cfg(feature = "default-tls")]
Tls(::native_tls::Error),
#[cfg(feature = "rustls-tls")]
Tls(::rustls::TLSError),
Copy link
Owner

Choose a reason for hiding this comment

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

In order to support when both default-tls and rustls-tls are enabled, these should probably become two variants, NativeTls and Rustls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if it makes sense to choose TLS backend at runtime, but I'll give it a try.

Copy link
Owner

Choose a reason for hiding this comment

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

Yea, it may not be the best to support both at runtime, and perhaps it should be changed to only 1 or the other, but I believe it'd be a breaking change. native-tls provides a couple features that rustls never will (disabling security), so we cannot add a non-default feature that doesn't have the same methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to avoid more complexity and overhead, I would rather support only one.

@quininer
Copy link
Contributor Author

I don't know how to make Certificate/Identity work at the same time in default-tls and rustls-tls.

@seanmonstar
Copy link
Owner

I don't know how to make Certificate/Identity work at the same time in default-tls and rustls-tls.

This doesn't sound fantastic, but it at least works: if both features are enabled, the Certificate and Identity could just hold a Vec<u8> internally, delaying the parsing until ClientBuilder::build(). The error will still be returned, eventually...

@quininer
Copy link
Contributor Author

quininer commented Nov 29, 2018

if both features are enabled, the Certificate and Identity could just hold a Vec<u8> internally, delaying the parsing until ClientBuilder::build().

This seems to make the API very counterintuitive.

Also if we want to use encrypted pkcs12, then we must Clone the password. Usually we don't want too many plaintext passwords in memory.

@quininer quininer changed the title [WIP] Add rustls support Add rustls support Dec 4, 2018
@quininer
Copy link
Contributor Author

@seanmonstar ping?

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

Phenomenal! (And sorry it feels gross...)

@@ -129,20 +213,34 @@ impl ClientBuilder {
})
}

/// Use native TLS backend.
#[cfg(feature = "default-tls")]
pub fn use_default_tls(mut self, tls: Option<TlsConnectorBuilder>) -> ClientBuilder {
Copy link
Owner

Choose a reason for hiding this comment

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

I'd remove the argument (and on use_rustls), to be conservative. That way, if they have breaking changes, we don't need to break as well just to upgrade.


/// Use rustls TLS backend.
#[cfg(feature = "rustls-tls")]
pub fn use_rustls_tls(mut self, tls: Option<rustls::ClientConfig>) -> ClientBuilder {
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think of the just use_rustls for the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For default-tls, do we named it use_default?

Copy link
Owner

Choose a reason for hiding this comment

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

No, I sort of felt rustls_tls is repetitive, but I don't feel strongly.

@seanmonstar seanmonstar merged commit 3703976 into seanmonstar:master Dec 17, 2018
@quininer quininer deleted the rustls branch January 7, 2022 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional rustls support
2 participants