Skip to content

Keep TLS verify settings ahead of REQUESTS_CA_BUNDLE - #3447

Open
Cherith1222 wants to merge 1 commit into
docker:mainfrom
Cherith1222:fix/2433-tls-ca-cert-precedence
Open

Cherith1222 wants to merge 1 commit into
docker:mainfrom
Cherith1222:fix/2433-tls-ca-cert-precedence

Conversation

@Cherith1222

Copy link
Copy Markdown

Summary

requests replaces a session's verify value with REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE when those variables are set. A ca_cert, or verify=False, passed through TLSConfig was therefore ignored. APIClient now overrides merge_environment_settings and uses self.verify when the request does not pass verify. If TLS is not configured, the environment variables still apply.

Fixes #2433. #2598 is the same override.

Test Plan

On Windows, Python 3.13:

  • pytest tests/unit/api_test.py -k TLSVerify → before the change, 2 failed.
  • After the change, tests/unit was 6 failed and 605 passed. The same command before the change was 8 failed and 603 passed. The remaining 6 failures also happen without this change and come from this machine's ~/.docker / Windows environment.
  • ruff 0.1.8 reported no warnings on the changed files.

Not run: tests/integration (needs a Docker daemon), a real TLS daemon, other Python versions, and non-Windows.

DCO

docker-py asks for a Developer Certificate of Origin sign-off. This commit does not include a Signed-off-by trailer. A human still needs to add that sign-off. It was not forged here.

AI assistance

Drafted with Cursor. The account owner authorized opening this pull request. A human has not reviewed the diff. There is no Co-authored-by, Reviewed-by, or Signed-off-by trailer.

requests lets REQUESTS_CA_BUNDLE/CURL_CA_BUNDLE replace a session's verify value, so a ca_cert (or verify=False) configured through TLSConfig was silently ignored when either variable was set. Use the client's verify setting when the request does not pass one.

Fixes docker#2433

AI-assisted (Cursor); not yet reviewed by a human.
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.

REQUESTS_CA_BUNDLE overrides docker.api.client.APIClient ca_cert init parameter

1 participant