Skip to content

maturin: use the platform trust store for uploads - #576571

Open
zimbatm wants to merge 1 commit into
NixOS:stagingfrom
zimbatm:cacert-maturin
Open

zimbatm wants to merge 1 commit into
NixOS:stagingfrom
zimbatm:cacert-maturin

Conversation

@zimbatm

@zimbatm zimbatm commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

maturin uses ureq with the rustls provider. The default ureq root store is the compiled-in webpki-roots list. That list still contains emSign ECC Root CA - G3, so a cacert update does not apply to it.

Make maturin upload / maturin publish (and the OIDC trusted publishing requests) use RootCerts::PlatformVerifier when no MATURIN_CA_BUNDLE / REQUESTS_CA_BUNDLE / CURL_CA_BUNDLE is set. On Linux this reads SSL_CERT_FILE, SSL_CERT_DIR or the system bundle. cargo-xwin already uses the platform verifier for its downloads.

Tested on x86_64-linux with maturin upload --repository-url https://test.pypi.org/legacy/ and a dummy token: with SSL_CERT_FILE holding one unrelated root, the old build completes TLS and sends the token (403), the new build fails with UnknownIssuer before authentication; with the system store and with no SSL_CERT_FILE it reaches the server as before. MATURIN_CA_BUNDLE still overrides. About 39,100 rebuilds (maturinBuildHook), hence staging.

Related to: #576485
Related to: #576544

Assisted-by: Claude Code (claude-opus-5)

Things done

maturin uses ureq with the rustls provider. The default ureq root store
is the compiled-in webpki-roots list. That list still contains
emSign ECC Root CA - G3, so a cacert update does not apply to it.

Make `maturin upload` / `maturin publish` (and the OIDC trusted
publishing requests) use RootCerts::PlatformVerifier when no
MATURIN_CA_BUNDLE / REQUESTS_CA_BUNDLE / CURL_CA_BUNDLE is set. On Linux
this reads SSL_CERT_FILE, SSL_CERT_DIR or the system bundle. cargo-xwin
already uses the platform verifier for its downloads.

See NixOS#576544.

Assisted-by: Claude Code (claude-opus-5)
@nixpkgs-ci
nixpkgs-ci Bot requested review from MiniHarinn and getchoo October 20, 2026 22:28
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 2.status: merge-bot eligible This PR can be merged by commenting "@NixOS/nixpkgs-merge-bot merge". llm-assisted Contributions that include code generation with LLMs labels Oct 20, 2026
@zimbatm zimbatm added the backport staging-26.05 Backport PR automatically label Oct 20, 2026
@thunder-coding

Copy link
Copy Markdown

You might be interested in seeing this patch I independently came up with: termux/termux-packages@1181d8a. Upstream might also consider accepting this patch considering distros would prefer using OS' certificates

thunder-coding added a commit to thunder-coding/maturin that referenced this pull request Oct 22, 2026
ureq bundles Mozilla's root certificates, and uses it as the default

This is especially helpful and needed for distro packagers having to
deal with eMudhra like situations. Trusting OS' cert store means distro
maintainers can essentially just update the ca-certificates (or
equivalent) package and call it a day instead of having to track all
packages that bundle their own certificates

This patch was earlier hand-written just for the `http_agent()` method,
but after finding out that `resolve_pypi_token_via_oidc()` also builds
it's own agent, LLM assistance was used to prevent code duplication to
extend my original patch's logic to this new function which I earlier
missed. The patch was thoroughly reviewed manually for correctness.

Patch earlier adopted by Termux in termux/termux-packages@1181d8a

Additionally a slightly ugly version of the patch was independently
created by a NixOS maintainer in NixOS/nixpkgs#576571
messense pushed a commit to PyO3/maturin that referenced this pull request Oct 22, 2026
…h native-tls (#3341)

ureq bundles Mozilla's root certificates, and uses it as the default

This is especially helpful and needed for distro packagers having to
deal with eMudhra like situations. Trusting OS' cert store means distro
maintainers can essentially just update the ca-certificates (or
equivalent) package and call it a day instead of having to track all
packages that bundle their own certificates

This patch was earlier hand-written just for the `http_agent()` method,
but after finding out that `resolve_pypi_token_via_oidc()` also builds
it's own agent, LLM assistance was used to prevent code duplication to
extend my original patch's logic to this new function which I earlier
missed. The patch was thoroughly reviewed manually for correctness.

Patch earlier adopted by Termux in
termux/termux-packages@1181d8a

Additionally a slightly ugly version of the patch was independently
created by a NixOS maintainer in
NixOS/nixpkgs#576571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge-bot eligible This PR can be merged by commenting "@NixOS/nixpkgs-merge-bot merge". 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. backport staging-26.05 Backport PR automatically llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants