File tree 5 files changed +30
-4
lines changed
5 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ impl Http {
10
10
. with_deviation (
11
11
"accepts the new 'default' value which means to use the curl default just like the empty string does" ,
12
12
) ;
13
+ /// The `http.sslVerify` key.
14
+ pub const SSL_VERIFY : keys:: Boolean = keys:: Boolean :: new_boolean ( "sslVerify" , & config:: Tree :: HTTP )
15
+ . with_deviation ( "Only supported when using curl as https backend" ) ;
13
16
/// The `http.proxy` key.
14
17
pub const PROXY : keys:: String =
15
18
keys:: String :: new_string ( "proxy" , & config:: Tree :: HTTP ) . with_deviation ( "fails on strings with illformed UTF-8" ) ;
Original file line number Diff line number Diff line change @@ -405,6 +405,15 @@ impl crate::Repository {
405
405
}
406
406
}
407
407
408
+ {
409
+ let key = "http.sslVerify" ;
410
+ debug_assert_eq ! ( key, config:: tree:: Http :: SSL_VERIFY . logical_name( ) ) ;
411
+ opts. ssl_verify = config
412
+ . boolean_filter_by_key ( key, & mut trusted_only)
413
+ . and_then ( Result :: ok)
414
+ . unwrap_or ( true )
415
+ }
416
+
408
417
#[ cfg( feature = "blocking-http-transport-curl" ) ]
409
418
{
410
419
let key = "http.schannelCheckRevoke" ;
Original file line number Diff line number Diff line change @@ -164,3 +164,8 @@ mkdir not-a-repo-with-files;
164
164
(cd not-a-repo-with-files
165
165
touch this that
166
166
)
167
+
168
+ git init no-ssl-verify
169
+ (cd no-ssl-verify
170
+ git config http.sslVerify false
171
+ )
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ mod http {
55
55
verbose,
56
56
ssl_ca_info,
57
57
ssl_version,
58
+ ssl_verify,
58
59
http_version,
59
60
backend,
60
61
} = http_options ( & repo, None , "https://example.com/does/not/matter" ) ;
@@ -106,6 +107,9 @@ mod http {
106
107
max: version
107
108
} )
108
109
) ;
110
+
111
+ assert ! ( ssl_verify, "SSL verification is enabled by default if not configured" ) ;
112
+
109
113
assert_eq ! ( http_version, Some ( HttpVersion :: V1_1 ) ) ;
110
114
}
111
115
@@ -314,4 +318,13 @@ mod http {
314
318
assert_eq ! ( opts. proxy. as_deref( ) , Some ( "http://localhost:9090" ) ) ;
315
319
assert_eq ! ( opts. follow_redirects, FollowRedirects :: Initial ) ;
316
320
}
321
+
322
+ #[ test]
323
+ fn no_ssl_verify ( ) {
324
+ let repo = repo ( "no-ssl-verify" ) ;
325
+
326
+ let opts = http_options ( & repo, None , "https://example.com/does/not/matter" ) ;
327
+
328
+ assert ! ( !opts. ssl_verify) ;
329
+ }
317
330
}
Original file line number Diff line number Diff line change @@ -408,10 +408,6 @@ static GIT_CONFIG: &[Record] = &[
408
408
config : "http.sslCipherList" ,
409
409
usage : NotPlanned { reason : "on demand" }
410
410
} ,
411
- Record {
412
- config : "http.sslVerify" ,
413
- usage : NotPlanned { reason : "on demand" }
414
- } ,
415
411
Record {
416
412
config : "http.sslCert" ,
417
413
usage : NotPlanned { reason : "on demand" }
You can’t perform that action at this time.
0 commit comments