Skip to content

python3Packages.botocore: use certifi for the CA bundle - #576583

Merged
zimbatm merged 1 commit into
NixOS:stagingfrom
zimbatm:cacert-botocore
Nov 23, 2026
Merged

zimbatm merged 1 commit into
NixOS:stagingfrom
zimbatm:cacert-botocore

Conversation

@zimbatm

@zimbatm zimbatm commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

botocore takes its CA bundle from certifi.where() when it can import
certifi, and falls back to its own cacert.pem otherwise. certifi was not
a dependency, so the fallback was always used. The nixpkgs certifi reads
NIX_SSL_CERT_FILE, and otherwise uses the cacert bundle.

Related to: #576485
Related to: #576541

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

Things done

@zimbatm zimbatm mentioned this pull request Oct 20, 2026
66 of 95 tasks
@nixpkgs-ci
nixpkgs-ci Bot requested a review from anthonyroussel October 20, 2026 22:42
@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-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-darwin: 2501-5000 This PR causes many rebuilds on Darwin and should target the staging branches. llm-assisted Contributions that include code generation with LLMs 6.topic: python Python is a high-level, general-purpose programming language. labels Oct 20, 2026
@zimbatm zimbatm added the backport staging-26.05 Backport PR automatically label Oct 20, 2026

@dotlambda dotlambda 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.

Why would we not use what botocore does upstream, i.e., rely on certifi? See https://github.com/boto/botocore/blob/1.43.117/botocore/httpsession.py#L96.
Certifi was patched to honor NIX_SSL_CERT_FILE in #205127.
Feel free to add support for SSL_CERT_FILE.

@blitz

blitz commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

FWIW this is the same workaround we applied to awscli: #576582

@samueldr-at-cyberus

Copy link
Copy Markdown
Contributor

Why would we not use what botocore does upstream, i.e., rely on certifi?

I'm not too familiar with botocore, but it looks like this is the fallback path when certifi is not used.

And I'm not entirely sure, because Python packaging in Nixpkgs is sometimes weird, but it looks like (without any other python environmental leakiness) certifi wouldn't be used by default

 $ git rev-parse HEAD
f4a03c008967841f2a0b3cb7c436fc6fc31671f6
 $ nix-store --query --requisites $(\nix-build --no-out-link --attr python3Packages.botocore) | grep -i certifi

So to properly handle this, I assume botocore would need to be fixed to make use of certifi.

And relatedly, I think if relying on certifi is the way forward (which I would say it probably should be, for the shared implementation) the fallback path probably should be dropped or made to fail.


Unrelated to the specific fix... Whatever is done, this is not an appropriate way to patch this. It is terribly misguided and absolutely wild.

If/whenever upstream decides to re-order or add classes to that file, the added where would be attached to some other random class leading to... literally who knows what.

@zimbatm, I know you know better than that regarding how to properly write Nixpkgs changes. Please critically self-review changes you send while thinking about the contributors and maintainers that will need to continue maintaining the packages.

botocore takes its CA bundle from certifi.where() when it can import
certifi, and falls back to its own cacert.pem otherwise. certifi was not
a dependency, so the fallback was always used. The nixpkgs certifi reads
NIX_SSL_CERT_FILE, and otherwise uses the cacert bundle.

Assisted-by: Claude Code (claude-opus-5)
@zimbatm zimbatm changed the title python3Packages.botocore: prefer the system CA bundle python3Packages.botocore: use certifi for the CA bundle Nov 11, 2026
@zimbatm

zimbatm commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Thanks @dotlambda @samueldr-at-cyberus, the certifi approach is much better agreed. Updated the PR. I'll send a follow-up for awscli2 too.

@zimbatm
zimbatm requested a review from dotlambda November 11, 2026 22:03

@snue snue 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.

I verified this works and does what it says. The certifi dependency is used. I couldn't nixpkgs-review the PR as the staging build is a bit much and also fails.

=== verdict ===
  [PASS] with-env: certifi is importable (PR adds it as dependency)
  [PASS] with-env: botocore CA bundle is certifi.where() == NIX_SSL_CERT_FILE
  [PASS] with-env: TLS handshake SUCCEEDS against the probe-CA server
  [PASS] no-env: certifi falls back to the system CA bundle
  [PASS] no-env: handshake REJECTED (probe CA not in system bundle)
  [PASS] no-certifi: botocore falls back to its own botocore/cacert.pem
  [PASS] no-certifi: NIX_SSL_CERT_FILE ignored (handshake REJECTED)
all 7 checks passed: this botocore takes its CA bundle from certifi and therefore honours NIX_SSL_CERT_FILE

Thanks for the improved fix!

@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Nov 12, 2026
@zimbatm
zimbatm added this pull request to the merge queue Nov 23, 2026
@zimbatm zimbatm mentioned this pull request Nov 23, 2026
3 of 13 tasks
Merged via the queue into NixOS:staging with commit 5c53ed0 Nov 23, 2026
31 checks passed
@zimbatm
zimbatm deleted the cacert-botocore branch November 23, 2026 19:02
@nixpkgs-ci

nixpkgs-ci Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for staging-26.05:

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

Labels

6.topic: python Python is a high-level, general-purpose programming language. 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 2501-5000 This PR causes many rebuilds on Darwin and should 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: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 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.

5 participants