Skip to content

python3Packages.stripe: use cacert bundle instead of vendored CA file - #577579

Merged
LeSuisse merged 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.stripe
Oct 23, 2026
Merged

LeSuisse merged 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.stripe

Conversation

@irgolic

@irgolic irgolic commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Part of #576541.

stripe-python has a bundled CA file, stripe/data/ca-certificates.crt. All HTTP clients of stripe-python use this file for API requests. They do not use certifi or SSL_CERT_FILE. This change replaces the installed file with a symlink to the ca-bundle.crt file of cacert in postFixup. Thus, the installed file is a symlink to cacert, and replaceDependencies can replace cacert. The wheel in the dist output keeps the bundled file (#576542).

Warning

AI Disclosure: Claude Code made the code change, the commit message and the first version of this pull request description. Claude Code used Claude Fable 5.1 and Claude Opus 5.5. I examined all of this work. Claude Code also wrote all of nix-cacert-harness. This pull request description is written in ASD-STE100 (Simplified Technical English), examined with memelint in strict mode.

Test

nix-cacert-harness examines the package before and after this change. A local copy of nixpkgs is not necessary.

nix run github:irgolic/nix-cacert-harness -- python3Packages.stripe --pr 577579
Harness output: python3Packages.stripe
$ nix run github:irgolic/nix-cacert-harness -- python3Packages.stripe --base 8915027df75d0403ef013dd0cbf09ff3c602fd03 --after github:irgolic/nixpkgs/d5057d1c98cec94c78f568f628238af4d6630108
base (before) = 8915027df75d0403ef013dd0cbf09ff3c602fd03
reference: fprs4zi8r6227x12qbsd1grvfrpz6201-nss-cacert-3.131.1 TLS roots=118 all=169
==================================================================
ATTR python3Packages.stripe
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/d5057d1c98cec94c78f568f628238af4d6630108
before ok (0 built, 2s)
        drv /nix/store/…-python3.14-stripe-15.5.1.drv
after  ok (0 built, 2s)
        drv /nix/store/…-python3.14-stripe-15.5.1.drv

| output:path | before | after |
|---|---|---|
| out:/lib/python3.14/site-packages/stripe/data/ca-certificates.crt | pem 144 certs: 19 not in cacert, 12 in cacert but not for TLS, 5 cacert TLS roots missing; scanner: ECC G3 | symlink->cacert:ca-bundle.crt pem 169 certs (118 TLS roots + 51 non-TLS, i.e. cacert's own trust-rules bundle) |

inside archives (scanner only; a symlink in the installed output cannot reach them, issue #576542 class):
  before dist:/stripe-15.5.1-py3-none-any.whl!stripe/data/ca-certificates.crt  roots=141 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  dist:/stripe-15.5.1-py3-none-any.whl!stripe/data/ca-certificates.crt  roots=141 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1

cacert in runtime closure (before): yes
cacert in runtime closure (after): yes
CAs trusted before but not trusted for TLS by cacert (31 total), e.g.:
  - C=IN, OU=emSign PKI, O=eMudhra Technologies Limited, CN=emSign ECC Root CA - G3
  - C=US, OU=emSign PKI, O=eMudhra Inc, CN=emSign ECC Root CA - C3
  - C=US, OU=emSign PKI, O=eMudhra Inc, CN=emSign Root CA - C1
  - C=AT, O=e-commerce monitoring GmbH, CN=GLOBALTRUST 2020
  - C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 2
  - C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 3
  - C=CH, O=SwissSign AG, CN=SwissSign Gold CA - G2
  - C=ES, O=Firmaprofesional SA, CN=FIRMAPROFESIONAL CA ROOT-A WEB
  - C=FR, O=Dhimyotis, CN=Certigna
VERDICT python3Packages.stripe: FIXED: before trusted CAs outside cacert; after: 1 store(s) == cacert, none with extra CAs (+ bundles inside archives remain, see above)

base=8915027df75d0403ef013dd0cbf09ff3c602fd03 shim=shims/python3Packages.stripe.nix
  package derivations to build for the matrix: 1 python3.14-stripe-15.5.1.drv
  before-stock: REFUSED -> /nix/store/…-ca-behave-python3Packages-stripe-stock
  before-test: REFUSED -> /nix/store/…-ca-behave-python3Packages-stripe-test
  after-stock: REFUSED -> /nix/store/…-ca-behave-python3Packages-stripe-stock
  after-test: CONNECTED -> /nix/store/…-ca-behave-python3Packages-stripe-test

python3Packages.stripe  (before 8915027df75d0403ef013dd0cbf09ff3c602fd03, after github:irgolic/nixpkgs/d5057d1c98cec94c78f568f628238af4d6630108)
         | stock cacert | + test root  | override with test-root cacert
before   | REFUSED      | REFUSED      | NO-OP (package does not take cacert)
after    | REFUSED      | CONNECTED    | yes (rebuilt with cacert + test root)
control (before cells): curl --cacert test-root: CONNECTED, curl --cacert stock: REFUSED
VERDICT python3Packages.stripe: PASS: after-fix trust follows cacert; before-fix ignores it

In the second part of the output, the harness adds a temporary test root to cacert and builds the package again. Then a small Python test sets stripe.api_base to the URL of a local openssl s_server and sends one API request, stripe.Balance.retrieve(). The certificate of this server chains to the test root. This server sends HTML, not data from the Stripe API. Thus, after the TLS connection, stripe-python stops with an APIError. The test counts this result as a connection. A certificate error gives an APIConnectionError. Before this change, cacert has no effect on the result. After this change, it has an effect.

Things done

Assisted-by: Claude Code (Claude Fable 5.1)
Assisted-by: Claude Code (Claude Opus 5.5)
@irgolic irgolic added 1.severity: security Issues which raise a security issue, or PRs that fix one llm-assisted Contributions that include code generation with LLMs labels Oct 23, 2026
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! 6.topic: python Python is a high-level, general-purpose programming language. labels Oct 23, 2026

@LeSuisse LeSuisse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks OK, merging.

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 577579
Commit: d5057d1c98cec94c78f568f628238af4d6630108


x86_64-linux

✅ 4 packages built:
  • python314Packages.stripe
  • python313Packages.stripe
  • gigalixir
  • pretix

@LeSuisse
LeSuisse added this pull request to the merge queue Oct 23, 2026
@LeSuisse LeSuisse added the backport release-26.05 Backport PR automatically label Oct 23, 2026
Merged via the queue into NixOS:master with commit 3eae6a1 Oct 23, 2026
37 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.severity: security Issues which raise a security issue, or PRs that fix one 6.topic: python Python is a high-level, general-purpose programming language. 7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! 8.has: port to stable This PR already has a backport to the stable release. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. backport release-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