Skip to content

Commit 11cf9c6

Browse files
authored
Merge pull request #1072 from GitGuardian/agateau/support-host-certs
Use system certificates
2 parents 2d6ff01 + 8bd1d73 commit 11cf9c6

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

.github/workflows/build_release_assets.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
- os: ubuntu-22.04
5555
# When building on Linux we use a container to build using an old enough version
5656
container: rockylinux/rockylinux:8
57+
sha256sum:
58+
python: e8d7ed8c6f8c6f85cd083d5051cafd8c6c01d09eca340d1da74d0c00ff1cb897
5759
- os: windows-2022
5860
- os: macos-13
5961
arch: x86_64
@@ -91,11 +93,22 @@ jobs:
9193
9294
# Install necessary packages
9395
yum install -y \
94-
python3.9 \
9596
git-core \
9697
findutils
9798
98-
echo PYTHON_CMD=/usr/bin/python3.9 >> $GITHUB_ENV
99+
# Install Python 3.10 (we can't use the one from setup-python@v5: it requires a more recent version of libc)
100+
PYTHON_VERSION=3.10.16
101+
PYTHON_BUILD=20250317
102+
scripts/download \
103+
https://github.com/indygreg/python-build-standalone/releases/download/${PYTHON_BUILD}/cpython-${PYTHON_VERSION}+${PYTHON_BUILD}-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz \
104+
python.tar.gz \
105+
${{ matrix.sha256sum.python }}
106+
107+
tar xf python.tar.gz
108+
109+
# Make Python available
110+
echo PATH=$PWD/python/bin:$PATH >> $GITHUB_ENV
111+
echo PYTHON_CMD=$PWD/python/bin/python >> $GITHUB_ENV
99112
100113
# Install NFPM
101114
NFPM_VERSION=2.36.1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Added
2+
3+
- ggshield now uses the system certificates instead of the bundled ones. Note that this only works with Python >= 3.10 (#1067).

ggshield/__main__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ def force_utf8_output():
179179
out.reconfigure(encoding="utf-8")
180180

181181

182+
def setup_truststore():
183+
"""Use the system certificates instead of the ones bundled by certifi"""
184+
if sys.version_info < (3, 10):
185+
# truststore requires Python 3.10
186+
return
187+
188+
import truststore
189+
190+
truststore.inject_into_ssl()
191+
192+
182193
def main(args: Optional[List[str]] = None) -> Any:
183194
"""
184195
Wrapper around cli.main() to handle the GITGUARDIAN_CRASH_LOG variable.
@@ -196,6 +207,7 @@ def main(args: Optional[List[str]] = None) -> Any:
196207
ui.set_ui(RichGGShieldUI())
197208

198209
force_utf8_output()
210+
setup_truststore()
199211

200212
show_crash_log = getenv_bool("GITGUARDIAN_CRASH_LOG")
201213
return cli.main(args, prog_name="ggshield", standalone_mode=not show_crash_log)

pdm.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dependencies = [
4949
"rich~=12.5.1",
5050
"typing-extensions~=4.12.2",
5151
"urllib3~=2.2.2",
52+
"truststore>=0.10.1; python_version >= \"3.10\"",
5253
]
5354

5455
[project.urls]

0 commit comments

Comments
 (0)