From e96936230d8116700121e16c93523a590b51d952 Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 18 Apr 2024 13:20:47 -0400 Subject: [PATCH 1/4] Ignore .envrc and .direnv/ --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 47657f4..b257f2a 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,10 @@ ENV/ env.bak/ venv.bak/ +# direnv +.envrc +.direnv/ + # Spyder project settings .spyderproject .spyproject From fdde55e5eb19b4c2775ddec3d4ddae0bfd12d07e Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 18 Apr 2024 13:40:09 -0400 Subject: [PATCH 2/4] Add support for TLDR_CERT environmental variable Setting TLDR_CERT will use that as the certificate bundle for updates --- tldr.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tldr.py b/tldr.py index 3de8220..0068588 100755 --- a/tldr.py +++ b/tldr.py @@ -34,12 +34,15 @@ USE_NETWORK = int(os.environ.get('TLDR_NETWORK_ENABLED', '1')) > 0 USE_CACHE = int(os.environ.get('TLDR_CACHE_ENABLED', '1')) > 0 MAX_CACHE_AGE = int(os.environ.get('TLDR_CACHE_MAX_AGE', 24*7)) +CAFILE = os.path.expanduser(os.environ.get('TLDR_CERT', None)) URLOPEN_CONTEXT = None if int(os.environ.get('TLDR_ALLOW_INSECURE', '0')) == 1: URLOPEN_CONTEXT = ssl.create_default_context() URLOPEN_CONTEXT.check_hostname = False URLOPEN_CONTEXT.verify_mode = ssl.CERT_NONE +elif CAFILE: + URLOPEN_CONTEXT = ssl.create_default_context(cafile=CAFILE) OS_DIRECTORIES = { "linux": "linux", From 2511aebe474e796452edc5a99b8cb8785a9067c0 Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 18 Apr 2024 13:46:59 -0400 Subject: [PATCH 3/4] Document TLDR_CERT in README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8853d63..bd45360 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,10 @@ For networks that sit behind a proxy, it may be necessary to disable SSL verific will disable SSL certificate inspection. This __should be avoided__ unless absolutely necessary. +It is possible to use a different certificate store/bundle by setting: + +* `TLDR_CERT=/path/to/certificates.crt` + ### Colors Values of the `TLDR_COLOR_x` variables may consist of three parts: From c7cd9f3b5075d7a0ecdc6a17c297da1ee8b7ffb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Brul=C3=A9?= Date: Tue, 6 Aug 2024 22:52:53 -0400 Subject: [PATCH 4/4] Update tldr.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use pathlib instead of os.path Co-authored-by: VĂ­tor Henrique <87824454+vitorhcl@users.noreply.github.com> --- tldr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tldr.py b/tldr.py index 0068588..48c34f7 100755 --- a/tldr.py +++ b/tldr.py @@ -34,7 +34,7 @@ USE_NETWORK = int(os.environ.get('TLDR_NETWORK_ENABLED', '1')) > 0 USE_CACHE = int(os.environ.get('TLDR_CACHE_ENABLED', '1')) > 0 MAX_CACHE_AGE = int(os.environ.get('TLDR_CACHE_MAX_AGE', 24*7)) -CAFILE = os.path.expanduser(os.environ.get('TLDR_CERT', None)) +CAFILE = None if os.environ.get('TLDR_CERT', None) is None else Path(os.environ.get('TLDR_CERT')).expanduser() URLOPEN_CONTEXT = None if int(os.environ.get('TLDR_ALLOW_INSECURE', '0')) == 1: