diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-01-04 23:15:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 00:15:52 +0100 |
commit | cbc2108525f3a01f4a944104457939b741c9898b (patch) | |
tree | 58f85bcd8998101762623737dc272bff81cad15a /runtime/http_util.rs | |
parent | 444eca80a93c2631623578c1febdedb43575a911 (diff) |
feat(cli/standalone): support runtime flags for deno compile (#8738)
Diffstat (limited to 'runtime/http_util.rs')
-rw-r--r-- | runtime/http_util.rs | 10 |
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); } |