summaryrefslogtreecommitdiff
path: root/runtime/http_util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/http_util.rs')
-rw-r--r--runtime/http_util.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/runtime/http_util.rs b/runtime/http_util.rs
index 67703c214..4fe4dc7ec 100644
--- a/runtime/http_util.rs
+++ b/runtime/http_util.rs
@@ -7,14 +7,12 @@ use deno_fetch::reqwest::header::HeaderMap;
use deno_fetch::reqwest::header::USER_AGENT;
use deno_fetch::reqwest::redirect::Policy;
use deno_fetch::reqwest::Client;
-use std::fs::File;
-use std::io::Read;
/// Create new instance of async reqwest::Client. This client supports
/// proxies and doesn't follow redirects.
pub fn create_http_client(
user_agent: String,
- ca_file: Option<&str>,
+ ca_data: Option<Vec<u8>>,
) -> Result<Client, AnyError> {
let mut headers = HeaderMap::new();
headers.insert(USER_AGENT, user_agent.parse().unwrap());
@@ -23,10 +21,8 @@ pub fn create_http_client(
.default_headers(headers)
.use_rustls_tls();
- if let Some(ca_file) = ca_file {
- let mut buf = Vec::new();
- File::open(ca_file)?.read_to_end(&mut buf)?;
- let cert = reqwest::Certificate::from_pem(&buf)?;
+ if let Some(ca_data) = ca_data {
+ let cert = reqwest::Certificate::from_pem(&ca_data)?;
builder = builder.add_root_certificate(cert);
}