diff options
author | Oscar Linde <lindeoscar@gmail.com> | 2020-07-13 01:18:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-12 19:18:27 -0400 |
commit | 3be2064803b127c1aaa4af4aa3f060bcc8e88049 (patch) | |
tree | c6a0b739903a536fc727430f8dac38c4b578fd65 | |
parent | e1d814055281ee2781dfda93cf8b2637b8d65800 (diff) |
feat(cli): add DENO_CERT environment variable (#6370)
-rw-r--r-- | cli/flags.rs | 1 | ||||
-rw-r--r-- | cli/global_state.rs | 6 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 21 |
3 files changed, 27 insertions, 1 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 7d9ba8fdb..efd0a5c63 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -186,6 +186,7 @@ static ENV_VARIABLES_HELP: &str = "ENVIRONMENT VARIABLES: DENO_DIR Set the cache directory DENO_INSTALL_ROOT Set deno install's output directory (defaults to $HOME/.deno/bin) + DENO_CERT Load certificate authority from PEM encoded file NO_COLOR Set to disable color HTTP_PROXY Proxy address for HTTP requests (module downloads, fetch) diff --git a/cli/global_state.rs b/cli/global_state.rs index e9988f4b5..3290be25f 100644 --- a/cli/global_state.rs +++ b/cli/global_state.rs @@ -58,6 +58,10 @@ impl GlobalState { let dir = deno_dir::DenoDir::new(custom_root)?; let deps_cache_location = dir.root.join("deps"); let http_cache = http_cache::HttpCache::new(&deps_cache_location); + let ca_file = flags + .ca_file + .clone() + .or_else(|| env::var("DENO_CERT").map(String::into).ok()); let file_fetcher = SourceFileFetcher::new( http_cache, @@ -65,7 +69,7 @@ impl GlobalState { flags.cache_blocklist.clone(), flags.no_remote, flags.cached_only, - flags.ca_file.clone(), + ca_file, )?; let ts_compiler = TsCompiler::new( diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index f064c4db1..935454636 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2183,6 +2183,27 @@ itest!(deno_lint_glob { }); #[test] +fn cafile_env_fetch() { + use url::Url; + let g = util::http_server(); + let deno_dir = TempDir::new().expect("tempdir fail"); + let module_url = + Url::parse("https://localhost:5545/cli/tests/cafile_url_imports.ts") + .unwrap(); + let cafile = util::root_path().join("cli/tests/tls/RootCA.pem"); + let output = Command::new(util::deno_exe_path()) + .env("DENO_DIR", deno_dir.path()) + .env("DENO_CERT", cafile) + .current_dir(util::root_path()) + .arg("cache") + .arg(module_url.to_string()) + .output() + .expect("Failed to spawn script"); + assert!(output.status.success()); + drop(g); +} + +#[test] fn cafile_fetch() { use url::Url; let g = util::http_server(); |