|
| 1 | +--- |
| 2 | +title: "Custom Trust" |
| 3 | +toc_hide: true |
| 4 | +weight: 2 |
| 5 | +--- |
| 6 | + |
| 7 | +In some cases, you may want to connect to a tool that uses a certificate from a certification authority (CA) that is not |
| 8 | +in the default trust store (e.g. a company-internal CA), which requires that you add custom trust to an existing trust |
| 9 | +store or replace the existing trust store with your own. |
| 10 | + |
| 11 | +## Using a Custom-Built DefectDojo Image |
| 12 | + |
| 13 | +When you are building your own container image for `django-DefectDojo`, you can simply add the certificates you would |
| 14 | +like to include as custom trust to the `docker/certs` path (see |
| 15 | +[Dockerfile.django](https://github.com/DefectDojo/django-DefectDojo/blob/861b617bfcb17cb5e858f46e31509134d0e98171/Dockerfile.django#L70)) |
| 16 | + |
| 17 | +## Using the Prebuilt DefectDojo Image |
| 18 | + |
| 19 | +1. Create a new mounted volume where the new trust store will be added (ensures persistence). |
| 20 | +2. Create a new trust store |
| 21 | + 1. Prepare a new PEM-encoded trust store file (`custom-cacerts.pem`). |
| 22 | + 2. Optional, if you want to keep existing trust: Add the custom trust to the existing trust store |
| 23 | + 1. Find the location of the existing trust store by running `python -m certifi` in the container |
| 24 | + 2. Append your custom trust to the existing trust store by running |
| 25 | + `cat cacert.pem custom-cacerts.pem > extended-cacerts.pem`. |
| 26 | + ***Important: The consequence of copying the existing trust store is that you will not receive any updates |
| 27 | + (added or removed CA certificates).*** |
| 28 | +3. Copy the new trust store (`custom-cacerts.pem` or `extended-cacerts.pem`) to the mounted volume. |
| 29 | +4. Point the environment variable `REQUESTS_CA_BUNDLE` to the new trust store file. |
| 30 | + |
| 31 | +> `REQUESTS_CA_BUNDLE` is an environment variable from the Python `requests` package. By default, it uses the trust |
| 32 | +> store provided by the `certifi` package. For more details, check the respective documentation |
| 33 | +> ([requests](https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification) or |
| 34 | +> [certifii](https://certifiio.readthedocs.io/en/latest/)) |
0 commit comments