@@ -44,38 +44,44 @@ impl Default for Remote {
44
44
let mut redirected_base_url = None :: < String > ;
45
45
let allow_redirects = Arc :: new ( atomic:: AtomicBool :: new ( false ) ) ;
46
46
47
- // We may error while configuring, which is expected as part of the internal protocol. The error will be
48
- // received and the sender of the request might restart us.
49
- let client = reqwest:: blocking:: ClientBuilder :: new ( )
50
- . connect_timeout ( std:: time:: Duration :: from_secs ( 20 ) )
51
- . http1_title_case_headers ( )
52
- . redirect ( reqwest:: redirect:: Policy :: custom ( {
53
- let allow_redirects = allow_redirects. clone ( ) ;
54
- move |attempt| {
55
- if allow_redirects. load ( atomic:: Ordering :: Relaxed ) {
56
- let curr_url = attempt. url ( ) ;
57
- let prev_urls = attempt. previous ( ) ;
47
+ fn setup_client_builder ( allow_redirects : Arc < atomic:: AtomicBool > ) -> reqwest:: blocking:: ClientBuilder {
48
+ reqwest:: blocking:: ClientBuilder :: new ( )
49
+ . connect_timeout ( std:: time:: Duration :: from_secs ( 20 ) )
50
+ . http1_title_case_headers ( )
51
+ . redirect ( reqwest:: redirect:: Policy :: custom ( {
52
+ move |attempt| {
53
+ if allow_redirects. load ( atomic:: Ordering :: Relaxed ) {
54
+ let curr_url = attempt. url ( ) ;
55
+ let prev_urls = attempt. previous ( ) ;
58
56
59
- match prev_urls. first ( ) {
60
- Some ( prev_url) if prev_url. host_str ( ) != curr_url. host_str ( ) => {
61
- // git does not want to be redirected to a different host.
62
- attempt. stop ( )
63
- }
64
- _ => {
65
- // emulate default git behaviour which relies on curl default behaviour apparently.
66
- const CURL_DEFAULT_REDIRS : usize = 50 ;
67
- if prev_urls. len ( ) >= CURL_DEFAULT_REDIRS {
68
- attempt. error ( "too many redirects" )
69
- } else {
70
- attempt. follow ( )
57
+ match prev_urls. first ( ) {
58
+ Some ( prev_url) if prev_url. host_str ( ) != curr_url. host_str ( ) => {
59
+ // git does not want to be redirected to a different host.
60
+ attempt. stop ( )
61
+ }
62
+ _ => {
63
+ // emulate default git behaviour which relies on curl default behaviour apparently.
64
+ const CURL_DEFAULT_REDIRS : usize = 50 ;
65
+ if prev_urls. len ( ) >= CURL_DEFAULT_REDIRS {
66
+ attempt. error ( "too many redirects" )
67
+ } else {
68
+ attempt. follow ( )
69
+ }
71
70
}
72
71
}
72
+ } else {
73
+ attempt. stop ( )
73
74
}
74
- } else {
75
- attempt. stop ( )
76
75
}
77
- }
78
- } ) )
76
+ } ) )
77
+ }
78
+
79
+ // We may error while configuring, which is expected as part of the internal protocol. The error will be
80
+ // received and the sender of the request might restart us.
81
+ let client_ssl_verify = setup_client_builder ( allow_redirects. clone ( ) ) . build ( ) ?;
82
+
83
+ let client_no_ssl_verify = setup_client_builder ( allow_redirects. clone ( ) )
84
+ . danger_accept_invalid_certs ( false )
79
85
. build ( ) ?;
80
86
81
87
for Request {
@@ -86,6 +92,12 @@ impl Default for Remote {
86
92
config,
87
93
} in req_recv
88
94
{
95
+ let client = if config. ssl_verify {
96
+ & client_ssl_verify
97
+ } else {
98
+ & client_no_ssl_verify
99
+ } ;
100
+
89
101
let effective_url = redirect:: swap_tails ( redirected_base_url. as_deref ( ) , & base_url, url. clone ( ) ) ;
90
102
let mut req_builder = if upload_body_kind. is_some ( ) {
91
103
client. post ( & effective_url)
0 commit comments