1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-05 13:59:01 -05:00

fix(cli): add support for DENO_CERT in upgrade command (#13862)

This commit is contained in:
Sylvain Cau 2022-03-19 06:40:44 +08:00 committed by Kitson Kelly
parent 3a106f08d8
commit b01a817f36

View file

@ -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);