Skip to content

feat(config): Add ssl_config to global_config (DM-3969)#2720

Open
haakonvt wants to merge 5 commits into
masterfrom
add-ssl-context-config
Open

feat(config): Add ssl_config to global_config (DM-3969)#2720
haakonvt wants to merge 5 commits into
masterfrom
add-ssl-context-config

Conversation

@haakonvt

Copy link
Copy Markdown
Contributor

feat(config): add ssl_context to GlobalConfig

Adds global_config.ssl_context (ssl.SSLContext | None) so users can configure custom certificate verification without relying on environment variables.

Motivation: The SDK migrated from requests to httpx, which dropped REQUESTS_CA_BUNDLE support. Users with corporate/internal CAs previously had to fall back to SSL_CERT_FILE/SSL_CERT_DIR. This gives them a clean in-code alternative.

@haakonvt
haakonvt requested review from a team as code owners July 13, 2026 12:52
@haakonvt haakonvt changed the title Add ssl context config (DM-3969) feat(config): Add ssl_config to global_config (DM-3969) Jul 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for configuring a custom ssl_context globally in GlobalConfig to enable certificate verification against custom CA bundles or the OS trust store, alongside updating the documentation. Key feedback includes using an explicit is not None check for ssl_context in the HTTP client to avoid issues with falsy mock objects, and removing a redundant ValueError in apply_settings that prevents programmatic configuration.

Comment thread cognite/client/config.py
Comment thread cognite/client/_http_client.py
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.65%. Comparing base (6757ba9) to head (86d404f).

Files with missing lines Patch % Lines
cognite/client/config.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2720      +/-   ##
==========================================
- Coverage   93.67%   93.65%   -0.02%     
==========================================
  Files         504      504              
  Lines       51112    51118       +6     
==========================================
- Hits        47878    47877       -1     
- Misses       3234     3241       +7     
Files with missing lines Coverage Δ
cognite/client/_http_client.py 93.42% <ø> (ø)
tests/tests_integration/test_api/test_workflows.py 87.43% <100.00%> (-0.97%) ⬇️
cognite/client/config.py 90.38% <66.66%> (-0.95%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@haakonvt
haakonvt force-pushed the add-ssl-context-config branch from a18b4c6 to 06c418e Compare July 13, 2026 13:17
@haakonvt
haakonvt force-pushed the add-ssl-context-config branch from 06c418e to 538473d Compare July 17, 2026 11:13
Comment thread cognite/client/config.py
disable_ssl (bool): Whether or not to disable SSL. Defaults to False
ssl_context (ssl.SSLContext | None): Custom SSL context for certificate verification. Overrides the
default certifi bundle. Ignored when ``disable_ssl`` is True. Must be set before the first API
request. Defaults to None. See https://cognite-sdk-python.readthedocs-hosted.com/en/latest/settings.html#ssl-certificate-configuration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Local render of docs:
Image

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.

2 participants