Skip to content

Commit 778e597

Browse files
AlvenixAbdullah Alyan
authored and
Abdullah Alyan
committed
Feat: In gix read http.sslVerify config value and pass it to gix-transport.
1 parent 369c565 commit 778e597

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

gix/src/config/tree/sections/http.rs

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ impl Http {
1010
.with_deviation(
1111
"accepts the new 'default' value which means to use the curl default just like the empty string does",
1212
);
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");
1316
/// The `http.proxy` key.
1417
pub const PROXY: keys::String =
1518
keys::String::new_string("proxy", &config::Tree::HTTP).with_deviation("fails on strings with illformed UTF-8");

gix/src/repository/config/transport.rs

+9
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,15 @@ impl crate::Repository {
405405
}
406406
}
407407

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+
408417
#[cfg(feature = "blocking-http-transport-curl")]
409418
{
410419
let key = "http.schannelCheckRevoke";

gix/tests/fixtures/make_config_repos.sh

+5
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,8 @@ mkdir not-a-repo-with-files;
164164
(cd not-a-repo-with-files
165165
touch this that
166166
)
167+
168+
git init no-ssl-verify
169+
(cd no-ssl-verify
170+
git config http.sslVerify false
171+
)

gix/tests/repository/config/transport_options.rs

+13
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ mod http {
5555
verbose,
5656
ssl_ca_info,
5757
ssl_version,
58+
ssl_verify,
5859
http_version,
5960
backend,
6061
} = http_options(&repo, None, "https://example.com/does/not/matter");
@@ -106,6 +107,9 @@ mod http {
106107
max: version
107108
})
108109
);
110+
111+
assert!(ssl_verify, "SSL verification is enabled by default if not configured");
112+
109113
assert_eq!(http_version, Some(HttpVersion::V1_1));
110114
}
111115

@@ -314,4 +318,13 @@ mod http {
314318
assert_eq!(opts.proxy.as_deref(), Some("http://localhost:9090"));
315319
assert_eq!(opts.follow_redirects, FollowRedirects::Initial);
316320
}
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+
}
317330
}

src/plumbing/progress.rs

-4
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,6 @@ static GIT_CONFIG: &[Record] = &[
408408
config: "http.sslCipherList",
409409
usage: NotPlanned { reason: "on demand" }
410410
},
411-
Record {
412-
config: "http.sslVerify",
413-
usage: NotPlanned { reason: "on demand" }
414-
},
415411
Record {
416412
config: "http.sslCert",
417413
usage: NotPlanned { reason: "on demand" }

0 commit comments

Comments
 (0)