-
Notifications
You must be signed in to change notification settings - Fork 37
feat(config): Add ssl_config to global_config (DM-3969)
#2720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
haakonvt
wants to merge
5
commits into
master
Choose a base branch
from
add-ssl-context-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+73
−4
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
74cf589
feat(config): add ssl_context to GlobalConfig for custom CA bundles a…
haakonvt 2ced2f9
docs(settings): add SSL certificate configuration section
haakonvt f1e64a8
docs(conf): ignore self-referential readthedocs links in linkcheck
haakonvt 538473d
docs(conf): use linkcheck_anchors_ignore instead of ignoring full URL
haakonvt 86d404f
make workflow test robust
haakonvt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import getpass | ||
| import pprint | ||
| import re | ||
| import ssl | ||
| import warnings | ||
| from typing import Any, ClassVar, NoReturn, overload | ||
|
|
||
|
|
@@ -30,6 +31,9 @@ class GlobalConfig: | |
| max_connection_pool_size (int): The maximum number of connections which will be kept in the SDKs connection pool. | ||
| Defaults to 20. | ||
| 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| proxy (str | None): Route all traffic (HTTP and HTTPS) via this proxy, e.g. ``http://localhost:8030``. | ||
| For proxy authentication, embed credentials in the URL: ``http://user:pass@localhost:8030``. | ||
| Defaults to None (no proxy). | ||
|
|
@@ -70,6 +74,7 @@ def __init__(self) -> None: | |
| self.max_retry_backoff: int = 60 | ||
| self.max_connection_pool_size: int = 20 | ||
| self.disable_ssl: bool = False | ||
| self.ssl_context: ssl.SSLContext | None = None | ||
| self.proxy: str | None = None | ||
| self._max_workers: int = 5 | ||
| self._concurrency_settings: ConcurrencySettings = ConcurrencySettings() | ||
|
|
@@ -92,6 +97,9 @@ def __setattr__(self, name: str, val: Any) -> None: | |
| case "file_download_chunk_size" | "file_upload_chunk_size" if val is not None and not is_positive_int(val): | ||
| raise ValueError(f"{name} must be a positive integer or None, got {val!r}") | ||
|
|
||
| case "ssl_context" if val is not None and not isinstance(val, ssl.SSLContext): | ||
| raise TypeError(f"ssl_context must be an ssl.SSLContext or None, got {type(val)!r}") | ||
|
|
||
| super().__setattr__(name, val) | ||
|
|
||
| @property | ||
|
|
@@ -156,6 +164,10 @@ def apply_settings(self, settings: dict[str, Any] | str) -> None: | |
| "Cannot apply 'concurrency_settings' via apply_settings. Modify the individual attributes on " | ||
| "'global_config.concurrency_settings' instead." | ||
| ) | ||
| if "ssl_context" in loaded: | ||
| raise ValueError( | ||
| "Cannot apply 'ssl_context' via apply_settings. Set 'global_config.ssl_context' directly instead." | ||
| ) | ||
|
haakonvt marked this conversation as resolved.
|
||
| if "default_client_config" in loaded: | ||
| if not isinstance(loaded["default_client_config"], ClientConfig): | ||
| loaded["default_client_config"] = ClientConfig.load(loaded["default_client_config"]) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Uh oh!
There was an error while loading. Please reload this page.