diff --git a/crates/rover-client/src/blocking/client.rs b/crates/rover-client/src/blocking/client.rs index 499654593..bb6cf85fe 100644 --- a/crates/rover-client/src/blocking/client.rs +++ b/crates/rover-client/src/blocking/client.rs @@ -8,6 +8,14 @@ use reqwest::{ use std::collections::HashMap; +pub(crate) fn get_client() -> Result { + ReqwestClient::builder() + .use_rustls_tls() + .tls_built_in_root_certs(true) + .gzip(true) + .build() +} + /// Represents a generic GraphQL client for making http requests. pub struct GraphQLClient { client: ReqwestClient, @@ -19,11 +27,7 @@ impl GraphQLClient { /// This client is used for generic GraphQL requests, such as introspection. pub fn new(graphql_endpoint: &str) -> Result { Ok(GraphQLClient { - client: ReqwestClient::builder() - .use_rustls_tls() - .tls_built_in_root_certs(true) - .gzip(true) - .build()?, + client: get_client()?, graphql_endpoint: graphql_endpoint.to_string(), }) } diff --git a/crates/rover-client/src/blocking/mod.rs b/crates/rover-client/src/blocking/mod.rs index e51e31143..516e45a1d 100644 --- a/crates/rover-client/src/blocking/mod.rs +++ b/crates/rover-client/src/blocking/mod.rs @@ -1,5 +1,6 @@ mod client; mod studio_client; +pub(crate) use client::get_client; pub use client::GraphQLClient; pub use studio_client::StudioClient; diff --git a/crates/rover-client/src/releases.rs b/crates/rover-client/src/releases.rs index 365648169..6bca1f8a6 100644 --- a/crates/rover-client/src/releases.rs +++ b/crates/rover-client/src/releases.rs @@ -1,12 +1,11 @@ -use crate::RoverClientError; +use crate::{blocking::get_client, RoverClientError}; use regex::Regex; -use reqwest::blocking; const LATEST_RELEASE_URL: &str = "https://github.com/apollographql/rover/releases/latest"; /// Looks up the latest release version, and returns it as a string pub fn get_latest_release() -> Result { - let res = blocking::Client::new().head(LATEST_RELEASE_URL).send()?; + let res = get_client()?.head(LATEST_RELEASE_URL).send()?; let release_url = res.url().to_string(); let release_url_parts: Vec<&str> = release_url.split('/').collect(); diff --git a/crates/sputnik/Cargo.toml b/crates/sputnik/Cargo.toml index e048dba93..269166ae8 100644 --- a/crates/sputnik/Cargo.toml +++ b/crates/sputnik/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" camino = "1.0" ci_info = { version = "0.14", features = ["serde-1"] } git2 = "0.13" -reqwest = { version = "0.11", features = ["blocking"] } +reqwest = { version = "0.11", features = ["blocking", "rustls-tls-native-roots"] } semver = { version = "1", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/crates/sputnik/src/session.rs b/crates/sputnik/src/session.rs index 706d2691a..ded167688 100644 --- a/crates/sputnik/src/session.rs +++ b/crates/sputnik/src/session.rs @@ -125,7 +125,10 @@ impl Session { let body = serde_json::to_string(&self)?; tracing::debug!("POSTing to {}", &self.reporting_info.endpoint); tracing::debug!("{}", body); - reqwest::blocking::Client::new() + reqwest::blocking::Client::builder() + .use_rustls_tls() + .tls_built_in_root_certs(true) + .build()? .post(self.reporting_info.endpoint.clone()) .body(body) .header("User-Agent", &self.reporting_info.user_agent)