Skip to content

Commit

Permalink
fix(hyper-rustls): reverted the hyper client to enforce https and add…
Browse files Browse the repository at this point in the history
…ed an insecure client builder
  • Loading branch information
Pierre Seguin committed Jun 6, 2022
1 parent aa06937 commit b404820
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,9 @@ pub trait HyperClientBuilder {
/// Create a hyper::Client
fn build_hyper_client(self) -> hyper::Client<Self::Connector>;

/// Create a `hyper::Client` (HTTPS not required)
fn build_insecure_http_hyper_client(self) -> hyper::Client<Self::Connector>;

/// Create a `hyper::Client` for tests (HTTPS not required)
#[doc(hidden)]
fn build_test_hyper_client(self) -> hyper::Client<Self::Connector>;
Expand Down Expand Up @@ -789,6 +792,22 @@ impl HyperClientBuilder for DefaultHyperClient {
type Connector = hyper_tls::HttpsConnector<hyper::client::connect::HttpConnector>;

fn build_hyper_client(self) -> hyper::Client<Self::Connector> {
#[cfg(feature = "hyper-rustls")]
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_only()
.enable_http1()
.enable_http2()
.build();
#[cfg(all(not(feature = "hyper-rustls"), feature = "hyper-tls"))]
let connector = hyper_tls::HttpsConnector::new();

hyper::Client::builder()
.pool_max_idle_per_host(0)
.build::<_, hyper::Body>(connector)
}

fn build_insecure_http_hyper_client(self) -> hyper::Client<Self::Connector> {
#[cfg(feature = "hyper-rustls")]
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
Expand Down Expand Up @@ -834,6 +853,10 @@ where
self
}

fn build_insecure_http_hyper_client(self) -> hyper::Client<C> {
self
}

fn build_test_hyper_client(self) -> hyper::Client<Self::Connector> {
self
}
Expand Down

0 comments on commit b404820

Please sign in to comment.