Skip to content

Commit ca4a3b1

Browse files
committed
Add http.proxy-cainfo config for proxy certs
This adds a `http.proxy-cainfo` option to Cargo which reads CA information from a bundle to pass through to the underlying `libcurl` call. This should allow configuration of Cargo in situations where SSL proxy is used.
1 parent c5f58e9 commit ca4a3b1

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/cargo/util/context/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,6 +2608,7 @@ pub struct CargoHttpConfig {
26082608
pub low_speed_limit: Option<u32>,
26092609
pub timeout: Option<u64>,
26102610
pub cainfo: Option<ConfigRelativePath>,
2611+
pub proxy_cainfo: Option<ConfigRelativePath>,
26112612
pub check_revoke: Option<bool>,
26122613
pub user_agent: Option<String>,
26132614
pub debug: Option<bool>,

src/cargo/util/network/http.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ pub fn configure_http_handle(gctx: &GlobalContext, handle: &mut Easy) -> CargoRe
6161
let cainfo = cainfo.resolve_path(gctx);
6262
handle.cainfo(&cainfo)?;
6363
}
64+
if let Some(proxy_cainfo) = &http.proxy_cainfo {
65+
let proxy_cainfo = proxy_cainfo.resolve_path(gctx);
66+
handle.proxy_cainfo(&format!("{}", proxy_cainfo.display()))?;
67+
}
6468
if let Some(check) = http.check_revoke {
6569
handle.ssl_options(SslOpt::new().no_revoke(!check))?;
6670
}

src/doc/src/reference/config.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ ssl-version.min = "tlsv1.1" # minimum TLS version
107107
timeout = 30 # timeout for each HTTP request, in seconds
108108
low-speed-limit = 10 # network timeout threshold (bytes/sec)
109109
cainfo = "cert.pem" # path to Certificate Authority (CA) bundle
110+
proxy-cainfo = "cert.pem" # path to proxy Certificate Authority (CA) bundle
110111
check-revoke = true # check for SSL certificate revocation
111112
multiplexing = true # HTTP/2 multiplexing
112113
user-agent = "" # the user-agent header
@@ -708,6 +709,14 @@ Sets the timeout for each HTTP request, in seconds.
708709
Path to a Certificate Authority (CA) bundle file, used to verify TLS
709710
certificates. If not specified, Cargo attempts to use the system certificates.
710711

712+
#### `http.proxy-cainfo`
713+
* Type: string (path)
714+
* Default: none
715+
* Environment: `CARGO_HTTP_PROXY_CAINFO`
716+
717+
Path to a Certificate Authority (CA) bundle file, used to verify proxy TLS
718+
certificates.
719+
711720
#### `http.check-revoke`
712721
* Type: boolean
713722
* Default: true (Windows) false (all others)

src/doc/src/reference/environment-variables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ In summary, the supported environment variables are:
105105
* `CARGO_HTTP_PROXY` --- Enables HTTP proxy, see [`http.proxy`].
106106
* `CARGO_HTTP_TIMEOUT` --- The HTTP timeout, see [`http.timeout`].
107107
* `CARGO_HTTP_CAINFO` --- The TLS certificate Certificate Authority file, see [`http.cainfo`].
108+
* `CARGO_HTTP_PROXY_CAINFO` --- The proxy TLS certificate Certificate Authority file, see [`http.proxy-cainfo`].
108109
* `CARGO_HTTP_CHECK_REVOKE` --- Disables TLS certificate revocation checks, see [`http.check-revoke`].
109110
* `CARGO_HTTP_SSL_VERSION` --- The TLS version to use, see [`http.ssl-version`].
110111
* `CARGO_HTTP_LOW_SPEED_LIMIT` --- The HTTP low-speed limit, see [`http.low-speed-limit`].
@@ -171,6 +172,7 @@ In summary, the supported environment variables are:
171172
[`http.proxy`]: config.md#httpproxy
172173
[`http.timeout`]: config.md#httptimeout
173174
[`http.cainfo`]: config.md#httpcainfo
175+
[`http.proxy-cainfo`]: config.md#httpproxy-cainfo
174176
[`http.check-revoke`]: config.md#httpcheck-revoke
175177
[`http.ssl-version`]: config.md#httpssl-version
176178
[`http.low-speed-limit`]: config.md#httplow-speed-limit

0 commit comments

Comments
 (0)