Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client certificates option to cargo #10630

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,18 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
if let Some(proxy) = http_proxy(config)? {
handle.proxy(&proxy)?;
}
if let Some(client_ssl_cert) = &http.client_ssl_cert {
let client_ssl_cert = client_ssl_cert.resolve_path(config);
handle.ssl_cert(&client_ssl_cert)?;
handle.ssl_cert_type("PEM")?;
}
if let Some(client_ssl_key) = &http.client_ssl_key {
let client_ssl_key = client_ssl_key.resolve_path(config);
handle.ssl_key(&client_ssl_key)?;
}
if let Some(client_ssl_key_password) = &http.client_ssl_key_password {
handle.key_password(client_ssl_key_password.as_str())?;
}
if let Some(cainfo) = &http.cainfo {
let cainfo = cainfo.resolve_path(config);
handle.cainfo(&cainfo)?;
Expand Down
3 changes: 3 additions & 0 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,9 @@ pub struct CargoHttpConfig {
pub debug: Option<bool>,
pub multiplexing: Option<bool>,
pub ssl_version: Option<SslVersionConfig>,
pub client_ssl_cert: Option<ConfigRelativePath>,
pub client_ssl_key: Option<ConfigRelativePath>,
pub client_ssl_key_password: Option<String>,
Comment on lines +2120 to +2122
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see a linked issue or discussion. We are wanting to discuss problems and solutions in Issues before moving on to implementation in PRs. This helps make sure we are all on the same page and reduces the pressure on the tight resources of the cargo team. For example, I would want more experienced people than I involved in the conversation about how the password should be handled to be both usable and secure.

We encourage people to discuss their design before hacking on code. This gives the Cargo team a chance to know your idea more. Sometimes after a discussion, we even find a way to solve the problem without coding! Typically, you file an issue or start a thread on the internals forum before submitting a pull request. Please read the process of how features and bugs are managed in Cargo.

https://doc.crates.io/contrib/process/working-on-cargo.html#before-hacking-on-cargo

See also https://blog.rust-lang.org/inside-rust/2022/03/31/cargo-team-changes.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also encourage following the PR template as that covers things like what the testing strategy for the implementation looks like.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made an issue explaining the design decisions, but to be honest the password one is impossible to solve without building a proper password manager in cargo.
Let me just point out that registry credentials are stored in plain text as well.

}

#[derive(Debug, Default, Deserialize, PartialEq)]
Expand Down