Skip to content

Commit

Permalink
Feature: log details about Certificates Authority bundle (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts authored Feb 19, 2024
2 parents 57476b2 + 9e61809 commit 425c20f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/guides/howto_behind_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Only HTTP and HTTPS proxies are supported. No socks, no PAC.
:::

> See [Requests official documentation](https://docs.python-requests.org/en/latest/user/advanced/#proxies)
## Passing as CLI option

- the proxy configuration is scoped to the QDT execution.
Expand Down Expand Up @@ -40,3 +42,30 @@ At the shell session scope:
> $env:QDT_PROXY_HTTP='http://user:password@proxyserver.intra:8765'
> qdt -vvv
```

----

## Defining custom SSL client certificates

Using a proxy for https connections typically requires the local machine to trust the proxy’s root certificate.

> See [Requests official documentation](https://docs.python-requests.org/en/latest/user/advanced/#ca-certificates)
### 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
```
10 changes: 10 additions & 0 deletions qgis_deployment_toolbelt/utils/journalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from socket import gethostname

# 3rd party
import certifi
from requests.utils import DEFAULT_CA_BUNDLE_PATH

# Imports depending on operating system
if "linux" in uname().system.lower():
import distro
Expand Down Expand Up @@ -131,6 +134,13 @@ def headers():
else:
logger.debug("No network proxies detected")

# SSL CA certificates
logger.debug(f"Installed certificate authority (CA) bundle: {certifi.where()}")
logger.debug(f"Default certificate authority (CA) bundle: {DEFAULT_CA_BUNDLE_PATH}")
logger.debug(
f"Certificate authority (CA) bundle to use: {getenv('REQUESTS_CA_BUNDLE', getenv('CURL_CA_BUNDLE'))}"
)


def get_logger_filepath() -> Path | None:
"""Retrieve log filepath within logger handlers.
Expand Down

0 comments on commit 425c20f

Please sign in to comment.