From b01a817f3642e8cab89da58591d35852f01a5795 Mon Sep 17 00:00:00 2001 From: Sylvain Cau Date: Sat, 19 Mar 2022 06:40:44 +0800 Subject: [PATCH] fix(cli): add support for DENO_CERT in upgrade command (#13862) --- cli/tools/upgrade.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index dfcb871d1c..531e724204 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -10,6 +10,7 @@ use deno_runtime::deno_fetch::reqwest; use deno_runtime::deno_fetch::reqwest::Client; use once_cell::sync::Lazy; use semver_parser::version::parse as semver_parse; +use std::env; use std::fs; use std::io::Write; use std::path::Path; @@ -33,7 +34,8 @@ pub async fn upgrade(upgrade_flags: UpgradeFlags) -> Result<(), AnyError> { let mut client_builder = Client::builder(); // If we have been provided a CA Certificate, add it into the HTTP client - if let Some(ca_file) = upgrade_flags.ca_file { + let ca_file = upgrade_flags.ca_file.or_else(|| env::var("DENO_CERT").ok()); + if let Some(ca_file) = ca_file { let buf = std::fs::read(ca_file)?; let cert = reqwest::Certificate::from_pem(&buf)?; client_builder = client_builder.add_root_certificate(cert);