-
Notifications
You must be signed in to change notification settings - Fork 202
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 https for native-tls backend #2316
Changes from all commits
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 |
---|---|---|
|
@@ -84,15 +84,18 @@ pub mod conns { | |
/// 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. | ||
/// It allows only https connections. | ||
/// To enable http connections, call `https_only(false)` on the retured NativeTls. | ||
pub fn native_tls() -> NativeTls { | ||
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)); | ||
let http = hyper::client::HttpConnector::new(); | ||
hyper_tls::HttpsConnector::from((http, tls.into())) | ||
let mut https = hyper_tls::HttpsConnector::from((http, tls.into())); | ||
https.https_only(true); | ||
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. I assume we'd want the same change in 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. I was thinking about that, but 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. I'd be quite wary of having diverging behaviour on something like this between the two TLS backends we support - that can turn out to be quite surprising for users. 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. If you think that consistency is (more) important in this case, then this PR can be scrapped. 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. My suggestion here is to apply the change to both backends, rather than to 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. So it looks like we would need a breaking change for this, either returning the builder from 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. Made a PR for this in 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.
|
||
https | ||
} | ||
|
||
#[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.
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.
Also:
retured
->returned
https_only(false)
->.https_only(false)