Skip to content

Commit

Permalink
fix: use rustls_tls for reqwest client
Browse files Browse the repository at this point in the history
  • Loading branch information
daltoncoder committed Jun 4, 2024
1 parent fc2eaaf commit 9bcaae7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/origin-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ affair.workspace = true
anyhow.workspace = true
fast-sri = { path = "../../lib/fast-sri" }
lightning-interfaces = { path = "../interfaces" }
reqwest = "0.11"
reqwest = { version = "0.11", features = ["rustls-tls"] }
serde.workspace = true
url = "2.5.0"
workspace-hack = { version = "0.1", path = "../../etc/workspace-hack" }
Expand Down
9 changes: 6 additions & 3 deletions core/origin-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::time::Duration;
use fast_sri::IntegrityMetadata;
use lightning_interfaces::prelude::*;
use lightning_interfaces::types::{Blake3Hash, CompressionAlgorithm};
use reqwest::{Client, Url};
use reqwest::{Client, ClientBuilder, Url};

pub use crate::config::Config;

Expand All @@ -27,7 +27,10 @@ impl<C: Collection> Clone for HttpOrigin<C> {

impl<C: Collection> HttpOrigin<C> {
pub fn new(_: Config, blockstore: C::BlockstoreInterface) -> anyhow::Result<Self> {
let client = Client::new();
let client = ClientBuilder::new()
.use_rustls_tls()
.build()
.expect("Unable to make reqwest https client in http origin");
Ok(Self { client, blockstore })
}

Expand All @@ -36,7 +39,7 @@ impl<C: Collection> HttpOrigin<C> {
let resp = self
.client
.get(url)
.timeout(Duration::from_millis(500))
.timeout(Duration::from_millis(1000))
.send()
.await?;
let mut data: Vec<u8> = resp.bytes().await?.into();
Expand Down

0 comments on commit 9bcaae7

Please sign in to comment.