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

Enable selecting system certificate stores. #787

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alilleybrinker
Copy link

This commit adds the ability to select what certificate root store to use when making HTTPS connections. Previously, cargo-release was configured to use the default for tame-index, which is the "webpki" root of trust maintained by Mozilla. This is a good and reasonable set of certificates, except for users on networks which substitute certificates.

Substituting certificates is something enterprise networks will frequently do so they can man-in-the-middle HTTPS connections made on their network and thus maintain visibility into the network activities of their employees. In this setup, the users' devices will generally be running enterprise-managed software which replaces certificates used by public websites with ones provided by the network software the enterprise uses, with the root certificates for these substituted chains being placed in the users' local system certificate store. In that case, with only the "webpki" certificate store loaded for cargo-release, the substituted certificates will fail to validate, and publication of new versions (indeed, even checking publication status of the crate attempting to be published) will fail with an HTTPS error about an untrusted certificate.

The solution chosen here was to add a configuration element, and a CLI flag under the "publish" section, which lets the user pick between "webpki" (Mozilla) or "native" (local system) certificate trust stores. The portion of the code in src/ops/index.rs which handles connecting to the registry index has been updated to configure which certificate store to use based on the user's selection.

The one final wrinkle is that we get reqwest, the dependency which actually handles HTTPS connections, through the tame-index crate, which re-exports it. To enable the APIs in reqwest for configuring what TLS certs to pick up, we have to enable the "native-certs" feature on tame-index, while leaving the default features on. This is something tame-index normally recommends against, because it assumes you want to exclusively activate one of them at compile time. In our case, we need the selection to happen at runtime, so we need both to be compiled in.

Fixes #764

let client = tame_index::external::reqwest::blocking::ClientBuilder::new()
.http2_prior_knowledge()
Copy link
Author

Choose a reason for hiding this comment

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

With native certs on, this line caused errors. This line turns off ALPN, so there's no ability to negotiate between HTTP versions. I am not sure why this was causing things to fail, but I kept getting errors with it on. The difference for removing this line is that ALPN is turned on, so HTTP version negotiation can occur.

src/ops/index.rs Outdated Show resolved Hide resolved
docs/reference.md Outdated Show resolved Hide resolved
docs/reference.md Outdated Show resolved Hide resolved
src/ops/index.rs Outdated Show resolved Hide resolved
src/ops/index.rs Outdated Show resolved Hide resolved
This commit adds the ability to select what certificate root store to
use when making HTTPS connections. Previously, `cargo-release` was
configured to use the default for `tame-index`, which is the "webpki"
root of trust maintained by Mozilla. This is a good and reasonable set
of certificates, _except_ for users on networks which substitute
certificates.

Substituting certificates is something enterprise networks will
frequently do so they can man-in-the-middle HTTPS connections made on
their network and thus maintain visibility into the network activities
of their employees. In this setup, the users' devices will generally be
running enterprise-managed software which replaces certificates used by
public websites with ones provided by the network software the
enterprise uses, with the root certificates for these substituted chains
being placed in the users' local system certificate store. In that case,
with only the "webpki" certificate store loaded for `cargo-release`, the
substituted certificates will fail to validate, and publication of new
versions (indeed, even checking publication status of the crate
attempting to be published) will fail with an HTTPS error about an
untrusted certificate.

The solution chosen here was to add a configuration element, and a CLI
flag under the "publish" section, which lets the user pick between
"webpki" (Mozilla) or "native" (local system) certificate trust stores.
The portion of the code in `src/ops/index.rs` which handles connecting
to the registry index has been updated to configure which certificate
store to use based on the user's selection.

The one final wrinkle is that we get `reqwest`, the dependency which
actually handles HTTPS connections, through the `tame-index` crate,
which re-exports it. To enable the APIs in `reqwest` for configuring
what TLS certs to pick up, we have to enable the "native-certs" feature
on `tame-index`, while leaving the default features on. This is
something `tame-index` normally recommends _against_, because it assumes
you want to exclusively activate one of them at compile time. In our
case, we need the selection to happen at runtime, so we need both to be
compiled in.

Signed-off-by: Andrew Lilley Brinker <abrinker@mitre.org>
@alilleybrinker
Copy link
Author

alilleybrinker commented May 13, 2024

Ended up opting to rebase down to one commit, and also fixed the table reformatting so the table is no longer reformatted at all, just has a row added for the new flag. If you'd still like that in its own commit separately, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Invalid peer certificate" when run on network which substitutes certs
2 participants