Skip to content

Commit

Permalink
chore: use rustls-tls-native-roots everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed Jul 2, 2021
1 parent d168848 commit b26f297
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
14 changes: 9 additions & 5 deletions crates/rover-client/src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ use reqwest::{

use std::collections::HashMap;

pub(crate) fn get_client() -> Result<ReqwestClient, ReqwestError> {
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,
Expand All @@ -19,11 +27,7 @@ impl GraphQLClient {
/// This client is used for generic GraphQL requests, such as introspection.
pub fn new(graphql_endpoint: &str) -> Result<GraphQLClient, ReqwestError> {
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(),
})
}
Expand Down
1 change: 1 addition & 0 deletions crates/rover-client/src/blocking/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod client;
mod studio_client;

pub(crate) use client::get_client;
pub use client::GraphQLClient;
pub use studio_client::StudioClient;
5 changes: 2 additions & 3 deletions crates/rover-client/src/releases.rs
Original file line number Diff line number Diff line change
@@ -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<String, RoverClientError> {
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();
Expand Down
2 changes: 1 addition & 1 deletion crates/sputnik/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion crates/sputnik/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b26f297

Please sign in to comment.