-
Notifications
You must be signed in to change notification settings - Fork 178
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
Enforce the same minimum TLS version (1.2) for both TLS backends #2312
Changes from all commits
571fc8f
1c67cba
97b3d33
568e9b8
55d7b69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -72,13 +72,27 @@ pub mod conns { | |||||
} | ||||||
|
||||||
#[cfg(feature = "rustls")] | ||||||
/// Return a default HTTPS connector backed by the `rustls` crate. | ||||||
/// | ||||||
/// It requires a minimum TLS version of 1.2. | ||||||
/// It allows you to connect to both `http` and `https` URLs. | ||||||
pub fn https() -> Https { | ||||||
HTTPS_NATIVE_ROOTS.clone() | ||||||
} | ||||||
|
||||||
#[cfg(feature = "native-tls")] | ||||||
/// Return a default HTTPS connector backed by the `hyper_tls` crate. | ||||||
/// | ||||||
/// It requires a minimum TLS version of 1.2. | ||||||
/// It allows you to connect to both `http` and `https` URLs. | ||||||
pub fn native_tls() -> NativeTls { | ||||||
hyper_tls::HttpsConnector::new() | ||||||
let mut tls = hyper_tls::native_tls::TlsConnector::builder(); | ||||||
let tls = tls | ||||||
.min_protocol_version(Some(hyper_tls::native_tls::Protocol::Tlsv12)) | ||||||
.build() | ||||||
.unwrap_or_else(|e| panic!("Error while creating TLS connector: {}", e)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: the convention we've been following for panic and |
||||||
let http = hyper::client::HttpConnector::new(); | ||||||
hyper_tls::HttpsConnector::from((http, tls.into())) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will still allow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added documentation to both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it's very clear, thank you! :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, otherwise you get the following compilation error:
|
||||||
} | ||||||
|
||||||
#[cfg(feature = "native-tls")] | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess returning an error here is too much of a breaking change right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also unnecessary - that should never fail since we are building the default configuration with known-good settings.