Skip to content

Commit 9f12fdb

Browse files
committed
Auto merge of #5097 - matklad:end-of-tls-saga-hopefully, r=alexcrichton
Revert "Warn Windows 7 users about old TLS" We now have upgraded libgit2 version, so Cargo would use TLS 1.2 on windows unconditionally. Note that even *unpatched* windows 7 supports TLS 1.2. @retep998, you've originally written that >TLS 1.2 support for Windows 7 still requires a rather recent patch and so even if we do fix that, we should still keep this error message because some people use Windows 7 with automatic updates disabled. However, it looks like Windows 7 **does** support TLS 1.2 out of the box, and the update is required to enable the use of TLS 1.2 by default: libgit2/libgit2#4546 (comment) My own testing on a random win 7 virtual box confirms this. closes #5066
2 parents bb927ce + 7458491 commit 9f12fdb

File tree

3 files changed

+12
-50
lines changed

3 files changed

+12
-50
lines changed

src/cargo/sources/git/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ pub fn with_fetch_options(git_config: &git2::Config,
591591
-> CargoResult<()>
592592
{
593593
let mut progress = Progress::new("Fetch", config);
594-
network::with_retry(config, url, || {
594+
network::with_retry(config, || {
595595
with_authentication(url.as_str(), git_config, |f| {
596596
let mut rcb = git2::RemoteCallbacks::new();
597597
rcb.credentials(f);

src/cargo/sources/registry/remote.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,14 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
224224
// TODO: don't download into memory, but ensure that if we ctrl-c a
225225
// download we should resume either from the start or the middle
226226
// on the next time
227+
let url = url.to_string();
227228
let mut handle = self.config.http()?.borrow_mut();
228229
handle.get(true)?;
229-
handle.url(&url.to_string())?;
230+
handle.url(&url)?;
230231
handle.follow_location(true)?;
231232
let mut state = Sha256::new();
232233
let mut body = Vec::new();
233-
network::with_retry(self.config, &url, || {
234+
network::with_retry(self.config, || {
234235
state = Sha256::new();
235236
body = Vec::new();
236237
let mut pb = Progress::new("Fetch", self.config);
@@ -249,10 +250,8 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
249250
}
250251
let code = handle.response_code()?;
251252
if code != 200 && code != 0 {
252-
let url = handle.effective_url()?
253-
.map(|url| url.to_string())
254-
.unwrap_or_else(|| url.to_string());
255-
Err(HttpNot200 { code, url }.into())
253+
let url = handle.effective_url()?.unwrap_or(&url);
254+
Err(HttpNot200 { code, url: url.to_string() }.into())
256255
} else {
257256
Ok(())
258257
}

src/cargo/util/network.rs

+6-43
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use curl;
22
use git2;
3-
use url::Url;
43

54
use failure::Error;
65

@@ -34,35 +33,6 @@ fn maybe_spurious(err: &Error) -> bool {
3433
false
3534
}
3635

37-
38-
/// Suggest the user to update their windows 7 to support modern TLS versions.
39-
/// See https://github.com/rust-lang/cargo/issues/5066 for details.
40-
#[cfg(windows)]
41-
fn should_warn_about_old_tls_for_win7(url: &Url, err: &Error) -> bool {
42-
let is_github = url.host_str() == Some("github.com");
43-
let is_cert_error = err.causes()
44-
.filter_map(|e| e.downcast_ref::<git2::Error>())
45-
.find(|e| e.class() == git2::ErrorClass::Net && e.code() == git2::ErrorCode::Certificate)
46-
.is_some();
47-
is_github && is_cert_error
48-
}
49-
50-
#[cfg(not(windows))]
51-
fn should_warn_about_old_tls_for_win7(_url: &Url, _err: &Error) -> bool {
52-
false
53-
}
54-
55-
const WIN7_TLS_WARNING: &str = "\
56-
Certificate check failure might be caused by outdated TLS on older versions of Windows.
57-
If you are using Windows 7, Windows Server 2008 R2 or Windows Server 2012,
58-
please follow these instructions to enable more secure TLS:
59-
60-
https://support.microsoft.com/en-us/help/3140245/
61-
62-
See https://github.com/rust-lang/cargo/issues/5066 for details.
63-
";
64-
65-
6636
/// Wrapper method for network call retry logic.
6737
///
6838
/// Retry counts provided by Config object `net.retry`. Config shell outputs
@@ -76,22 +46,17 @@ See https://github.com/rust-lang/cargo/issues/5066 for details.
7646
/// use util::network;
7747
/// cargo_result = network::with_retry(&config, || something.download());
7848
/// ```
79-
pub fn with_retry<T, F>(config: &Config, url: &Url, mut callback: F) -> CargoResult<T>
49+
pub fn with_retry<T, F>(config: &Config, mut callback: F) -> CargoResult<T>
8050
where F: FnMut() -> CargoResult<T>
8151
{
8252
let mut remaining = config.net_retry()?;
8353
loop {
8454
match callback() {
8555
Ok(ret) => return Ok(ret),
8656
Err(ref e) if maybe_spurious(e) && remaining > 0 => {
87-
config.shell().warn(
88-
format!("spurious network error ({} tries remaining): {}", remaining, e)
89-
)?;
90-
91-
if should_warn_about_old_tls_for_win7(url, e) {
92-
config.shell().warn(WIN7_TLS_WARNING)?;
93-
}
94-
57+
let msg = format!("spurious network error ({} tries \
58+
remaining): {}", remaining, e);
59+
config.shell().warn(msg)?;
9560
remaining -= 1;
9661
}
9762
//todo impl from
@@ -106,8 +71,7 @@ fn with_retry_repeats_the_call_then_works() {
10671
let error2 = HttpNot200 { code: 502, url: "Uri".to_string() }.into();
10772
let mut results: Vec<CargoResult<()>> = vec![Ok(()), Err(error1), Err(error2)];
10873
let config = Config::default().unwrap();
109-
let url = "http://example.com".parse().unwrap();
110-
let result = with_retry(&config, &url, || results.pop().unwrap());
74+
let result = with_retry(&config, || results.pop().unwrap());
11175
assert_eq!(result.unwrap(), ())
11276
}
11377

@@ -123,7 +87,6 @@ fn with_retry_finds_nested_spurious_errors() {
12387
let error2 = CargoError::from(error2.context("A second chained error"));
12488
let mut results: Vec<CargoResult<()>> = vec![Ok(()), Err(error1), Err(error2)];
12589
let config = Config::default().unwrap();
126-
let url = "http://example.com".parse().unwrap();
127-
let result = with_retry(&config, &url, || results.pop().unwrap());
90+
let result = with_retry(&config, || results.pop().unwrap());
12891
assert_eq!(result.unwrap(), ())
12992
}

0 commit comments

Comments
 (0)