-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: network use native system stores (#444)
By default, a bundle of SSL certificates is used, through [certifi](https://pypi.org/project/certifi/). This PR allows QDT to use the system certificates store. In this PR: - add [truststore](https://truststore.readthedocs.io/en/latest/#using-truststore-with-requests) as dependency to use new Python APIs (3.10) to deal with native system certs stores - add a new `QDT_SSL_USE_SYSTEM_STORES` environment variable to enable this feature as an opt-in - add related documentation Related documentation: https://guts.github.io/qgis-deployment-cli/guides/howto_behind_proxy.html#id1 cc @DeCiZoR and @Niarolf
- Loading branch information
Showing
7 changed files
with
79 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Defining custom SSL client certificates | ||
|
||
Using a [proxy](./howto_behind_proxy.md) for https connections typically requires the local machine to trust the proxy’s root certificate. By default, a bundle of SSL certificates is used, through [certifi](https://pypi.org/project/certifi/) (using Mozilla curated list). | ||
|
||
> See [Requests official documentation](https://docs.python-requests.org/en/latest/user/advanced/#ca-certificates) | ||
Here comes how to customize which certificates bundle to use or how to require QDT to use the native system certificates store. | ||
|
||
## Using `REQUESTS_CA_BUNDLE` or `CURL_CA_BUNDLE` | ||
|
||
Point to a certificat bundle file path (*.pem). | ||
|
||
### Example on Windows PowerShell | ||
|
||
Only for the QDT command scope: | ||
|
||
```powershell | ||
$env:REQUESTS_CA_BUNDLE="$env:USERPROFILE\cacerts.pem"; qdt -vvv | ||
``` | ||
|
||
At the shell session scope: | ||
|
||
```powershell | ||
> $env:REQUESTS_CA_BUNDLE="$env:USERPROFILE\cacerts.pem" | ||
> qdt -vvv | ||
``` | ||
|
||
## Using native system certificates store | ||
|
||
If the `QDT_SSL_USE_SYSTEM_STORES` environment variable is set to `True`, HTTPS requests rely on the native system certificates store. | ||
|
||
:::{info} | ||
If enabled, this environment variable take precedence over `REQUESTS_CA_BUNDLE` or `CURL_CA_BUNDLE` which are ignored. | ||
::: | ||
|
||
### Example on Windows PowerShell | ||
|
||
Only for the QDT command scope: | ||
|
||
```powershell | ||
$env:QDT_SSL_USE_SYSTEM_STORES=true; qdt -vvv | ||
``` | ||
|
||
At the shell session scope: | ||
|
||
```powershell | ||
> $env:QDT_SSL_USE_SYSTEM_STORES=true | ||
> qdt -vvv | ||
``` |
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ packaging>=20,<24 | |
pyyaml>=5.4,<7 | ||
pywin32==306 ; sys_platform == 'win32' | ||
requests>=2.31,<3 | ||
truststore>=0.8,<1 |