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