Skip to content

python3Packages.httplib2: use cacert bundle instead of vendored CA file - #577080

Open
irgolic wants to merge 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.httplib2
Open

irgolic wants to merge 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.httplib2

Conversation

@irgolic

@irgolic irgolic commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Part of #576541. This pull request is #489081, rebased on the master branch, and has a Co-authored-by line for the person who wrote #489081.

httplib2 has a bundled CA file, cacerts.txt. 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.httplib2 --pr 577080
Harness output: installed package
$ nix run github:irgolic/nix-cacert-harness -- python3Packages.httplib2 --base 8915027df75d0403ef013dd0cbf09ff3c602fd03 --after github:irgolic/nixpkgs/8e60aed8faacaa025a574bfa8df22c25340a502f
base (before) = 8915027df75d0403ef013dd0cbf09ff3c602fd03
reference: fprs4zi8r6227x12qbsd1grvfrpz6201-nss-cacert-3.131.1 TLS roots=118 all=169
==================================================================
ATTR python3Packages.httplib2
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/8e60aed8faacaa025a574bfa8df22c25340a502f
before ok (0 built, 2s)
        drv /nix/store/…-python3.14-httplib2-0.32.0.drv
after  ok (0 built, 1s)
        drv /nix/store/…-python3.14-httplib2-0.32.0.drv

| output:path | before | after |
|---|---|---|
| out:/lib/python3.14/site-packages/httplib2/cacerts.txt | pem 71 certs: 55 not in cacert, 8 in cacert but not for TLS, 110 cacert TLS roots missing; scanner: AAA | 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:/httplib2-0.32.0-py3-none-any.whl!httplib2/cacerts.txt  roots=40 trusts AAA Certificate Services
  after  dist:/httplib2-0.32.0-py3-none-any.whl!httplib2/cacerts.txt  roots=40 trusts AAA Certificate Services

cacert in runtime closure (before): no
cacert in runtime closure (after): yes
CAs trusted before but not trusted for TLS by cacert (63 total), e.g.:
  - C=GB, O=Comodo CA Limited, CN=AAA Certificate Services
  - C=BE, O=GlobalSign nv-sa, OU=Root CA, CN=GlobalSign Root CA
  - C=DE, O=TC TrustCenter GmbH, OU=TC TrustCenter Class 2 CA, CN=TC TrustCenter Class 2 CA II
  - C=DE, O=TC TrustCenter GmbH, OU=TC TrustCenter Class 3 CA, CN=TC TrustCenter Class 3 CA II
  - C=DE, O=TC TrustCenter GmbH, OU=TC TrustCenter Universal CA, CN=TC TrustCenter Universal CA I
  - C=DE, O=TC TrustCenter GmbH, OU=TC TrustCenter Universal CA, CN=TC TrustCenter Universal CA III
  - C=GB, O=COMODO CA Limited, CN=COMODO Certification Authority
VERDICT python3Packages.httplib2: 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/python-lib.nix
  package derivations to build for the matrix: 1 python3.14-httplib2-0.32.0.drv
  before-stock: REFUSED -> /nix/store/…-ca-behave-python3Packages-httplib2-stock
  before-test: REFUSED -> /nix/store/…-ca-behave-python3Packages-httplib2-test
  after-stock: REFUSED -> /nix/store/…-ca-behave-python3Packages-httplib2-stock
  after-test: CONNECTED -> /nix/store/…-ca-behave-python3Packages-httplib2-test

python3Packages.httplib2  (before 8915027df75d0403ef013dd0cbf09ff3c602fd03, after github:irgolic/nixpkgs/8e60aed8faacaa025a574bfa8df22c25340a502f)
         | 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.httplib2: 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 httplib2 sends a request to a local openssl s_server. The certificate of this server chains to the test root. 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)
Co-authored-by: sinrohit-desco <[email protected]>
@zimbatm zimbatm mentioned this pull request Oct 21, 2026
66 of 95 tasks
@tree-sapii tree-sapii 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 21, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from fabaff October 21, 2026 22:42
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 6.topic: python Python is a high-level, general-purpose programming language. labels Oct 21, 2026
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Oct 21, 2026
@NickCao

NickCao commented Oct 22, 2026

Copy link
Copy Markdown
Member

#489081 's approach is to be preferred over this one, as rm would fail if cacerts.txt is not in that location, while ln -sf would not. Also doing this in postPatch would cause the resulting package still carry a copy of the certificate, while doing it in postFixup result in the cert file being a proper symlink, allowing for replaceDependencies to work.

@irgolic

irgolic commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Thanks, will fix this in the morning

@irgolic
irgolic force-pushed the cacert/python3Packages.httplib2 branch from e4b7d4c to 8e60aed Compare October 22, 2026 11:58
@irgolic

irgolic commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

I've moved the postPatch to postFixup. As such this PR no longer patches the wheel; that will need a separate fix.

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. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants