-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip proxies with MITM root certificates by setting RUSTUP_USE_UNSAFE…
…_SSL environment variable
- Loading branch information
1 parent
b697df1
commit 1e6c852
Showing
14 changed files
with
252 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,42 @@ | ||
#![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 | ||
|
||
#[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"); | ||
} |
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,27 @@ | ||
#![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 reqwest handles | ||
/// and all tests in one file use either the safe or the unsafe handle | ||
|
||
#[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", "1"); | ||
|
||
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,42 @@ | ||
#![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 handles | ||
/// and all tests in one file use either the safe or the unsafe handle | ||
|
||
#[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"); | ||
} |
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,27 @@ | ||
#![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 handles | ||
/// and all tests in one file use either the safe or the unsafe handle | ||
|
||
#[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", "1"); | ||
|
||
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.
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
Oops, something went wrong.