-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for proxies with MITM root certificates
Added RUSTUP_USE_UNSAFE_SSL environment variable.
- Loading branch information
1 parent
b697df1
commit 946632f
Showing
14 changed files
with
297 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#![cfg(feature = "curl-backend")] | ||
|
||
use download::*; | ||
|
||
mod support; | ||
use crate::support::{file_contents, serve_file, tmp_dir}; | ||
|
||
// There are two separate files because this crate caches curl handles | ||
// and all tests in one file use either the safe or the unsafe handle. | ||
// See download-curl-unsafe.rs for the complementary test case. | ||
|
||
#[test] | ||
fn downloading_with_no_certificate() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), false); | ||
let from_url = format!("http://{}", addr).parse().unwrap(); | ||
|
||
download_to_path_with_backend(Backend::Curl, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn downloading_with_bad_certificate() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), true); | ||
let from_url = format!("https://{}", addr).parse().unwrap(); | ||
|
||
std::env::remove_var("RUSTUP_USE_UNSAFE_SSL"); | ||
|
||
assert_eq!(std::env::var_os("RUSTUP_USE_UNSAFE_SSL").is_none(), true); | ||
|
||
download_to_path_with_backend(Backend::Curl, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn downloading_with_bad_certificate_using_wrong_env_value() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), true); | ||
let from_url = format!("https://{}", addr).parse().unwrap(); | ||
|
||
std::env::set_var("RUSTUP_USE_UNSAFE_SSL", "FOOBAR"); | ||
|
||
assert_eq!(std::env::var_os("RUSTUP_USE_UNSAFE_SSL").is_some(), true); | ||
|
||
download_to_path_with_backend(Backend::Curl, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![cfg(feature = "curl-backend")] | ||
|
||
use download::*; | ||
|
||
mod support; | ||
use crate::support::{file_contents, serve_file, tmp_dir}; | ||
|
||
// There are two separate files because this crate caches curl handles | ||
// and all tests in one file use either the safe or the unsafe handle. | ||
// See download-curl-safe.rs for the complementary test case. | ||
|
||
#[test] | ||
fn downloading_with_bad_certificate_unsafely() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), true); | ||
let from_url = format!("https://{}", addr).parse().unwrap(); | ||
|
||
std::env::set_var("RUSTUP_USE_UNSAFE_SSL", "ACCEPT_RISKS"); | ||
|
||
assert_eq!(std::env::var_os("RUSTUP_USE_UNSAFE_SSL").is_some(), true); | ||
|
||
download_to_path_with_backend(Backend::Curl, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#![cfg(feature = "reqwest-backend")] | ||
|
||
use download::*; | ||
|
||
mod support; | ||
use crate::support::{file_contents, serve_file, tmp_dir}; | ||
|
||
// There are two separate files because this crate caches reqwest clients | ||
// and all tests in one file use either the safe or the unsafe client. | ||
// See download-reqwest-unsafe.rs for the complementary test case. | ||
|
||
#[test] | ||
fn downloading_with_no_certificate() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), false); | ||
let from_url = format!("http://{}", addr).parse().unwrap(); | ||
|
||
download_to_path_with_backend(Backend::Reqwest, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn downloading_with_bad_certificate() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), true); | ||
let from_url = format!("https://{}", addr).parse().unwrap(); | ||
|
||
std::env::remove_var("RUSTUP_USE_UNSAFE_SSL"); | ||
|
||
assert_eq!(std::env::var_os("RUSTUP_USE_UNSAFE_SSL").is_none(), true); | ||
|
||
download_to_path_with_backend(Backend::Reqwest, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn downloading_with_bad_certificate_using_wrong_env_value() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), true); | ||
let from_url = format!("https://{}", addr).parse().unwrap(); | ||
|
||
std::env::set_var("RUSTUP_USE_UNSAFE_SSL", "FOOBAR"); | ||
|
||
assert_eq!(std::env::var_os("RUSTUP_USE_UNSAFE_SSL").is_some(), true); | ||
|
||
download_to_path_with_backend(Backend::Reqwest, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![cfg(feature = "reqwest-backend")] | ||
|
||
use download::*; | ||
|
||
mod support; | ||
use crate::support::{file_contents, serve_file, tmp_dir}; | ||
|
||
// There are two separate files because this crate caches reqwest clients | ||
// and all tests in one file use either the safe or the unsafe client. | ||
// See download-reqwest-safe.rs for the complementary test case. | ||
|
||
#[test] | ||
fn downloading_with_bad_certificate_unsafely() { | ||
let tmpdir = tmp_dir(); | ||
let target_path = tmpdir.path().join("downloaded"); | ||
|
||
let addr = serve_file(b"12345".to_vec(), true); | ||
let from_url = format!("https://{}", addr).parse().unwrap(); | ||
|
||
std::env::set_var("RUSTUP_USE_UNSAFE_SSL", "ACCEPT_RISKS"); | ||
|
||
assert_eq!(std::env::var_os("RUSTUP_USE_UNSAFE_SSL").is_some(), true); | ||
|
||
download_to_path_with_backend(Backend::Reqwest, &from_url, &target_path, false, None) | ||
.expect("Test download failed"); | ||
|
||
assert_eq!(file_contents(&target_path), "12345"); | ||
} |
Binary file not shown.
Oops, something went wrong.