@@ -33,6 +33,33 @@ fn maybe_spurious(err: &Error) -> bool {
33
33
false
34
34
}
35
35
36
+
37
+ /// Suggest the user to update their windows 7 to support modern TLS versions.
38
+ /// See https://github.com/rust-lang/cargo/issues/5066 for details.
39
+ #[ cfg( windows) ]
40
+ fn should_warn_about_old_tls_for_win7 ( err : & Error ) -> bool {
41
+ err. causes ( )
42
+ . filter_map ( |e| e. downcast_ref :: < git2:: Error > ( ) )
43
+ . find ( |e| e. class ( ) == git2:: ErrorClass :: Net && e. code ( ) == git2:: ErrorCode :: Certificate )
44
+ . is_some ( )
45
+ }
46
+
47
+ #[ cfg( not( windows) ) ]
48
+ fn should_warn_about_old_tls_for_win7 ( _err : & Error ) -> bool {
49
+ false
50
+ }
51
+
52
+ const WIN7_TLS_WARNING : & str = "\
53
+ Certificate check failure might be caused by outdated TLS on older versions of Windows.
54
+ If you are using Windows 7, Windows Server 2008 R2 or Windows Server 2012,
55
+ please follow these instructions to enable more secure TLS:
56
+
57
+ https://support.microsoft.com/en-us/help/3140245/
58
+
59
+ See https://github.com/rust-lang/cargo/issues/5066 for details.
60
+ " ;
61
+
62
+
36
63
/// Wrapper method for network call retry logic.
37
64
///
38
65
/// Retry counts provided by Config object `net.retry`. Config shell outputs
@@ -54,9 +81,14 @@ pub fn with_retry<T, F>(config: &Config, mut callback: F) -> CargoResult<T>
54
81
match callback ( ) {
55
82
Ok ( ret) => return Ok ( ret) ,
56
83
Err ( ref e) if maybe_spurious ( e) && remaining > 0 => {
57
- let msg = format ! ( "spurious network error ({} tries \
58
- remaining): {}", remaining, e) ;
59
- config. shell ( ) . warn ( msg) ?;
84
+ config. shell ( ) . warn (
85
+ format ! ( "spurious network error ({} tries remaining): {}" , remaining, e)
86
+ ) ?;
87
+
88
+ if should_warn_about_old_tls_for_win7 ( e) {
89
+ config. shell ( ) . warn ( WIN7_TLS_WARNING ) ?;
90
+ }
91
+
60
92
remaining -= 1 ;
61
93
}
62
94
//todo impl from
0 commit comments