Skip to content

Commit b5bfe14

Browse files
jtcbrulevitorhclCleanMachine1kbdharun
authored
Allow specifying a certificate bundle with TLDR_CERT (#243)
* .gitignore: ignore .envrc and .direnv/ * Add support for TLDR_CERT environmental variable Setting TLDR_CERT will use that as the certificate bundle for updates * Document TLDR_CERT in README --------- Co-authored-by: Vítor Henrique <87824454+vitorhcl@users.noreply.github.com> Co-authored-by: CleanMachine1 <78213164+CleanMachine1@users.noreply.github.com> Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
1 parent ff2b92b commit b5bfe14

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ ENV/
114114
env.bak/
115115
venv.bak/
116116

117+
# direnv
118+
.envrc
119+
.direnv/
120+
117121
# Spyder project settings
118122
.spyderproject
119123
.spyproject

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ For networks that sit behind a proxy, it may be necessary to disable SSL verific
137137

138138
will disable SSL certificate inspection. This __should be avoided__ unless absolutely necessary.
139139

140+
Alternatively, It is possible to use a different certificate store/bundle by setting:
141+
142+
* `TLDR_CERT=/path/to/certificates.crt`
143+
140144
### Colors
141145

142146
Values of the `TLDR_COLOR_x` variables may consist of three parts:

tldr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@
3434
USE_NETWORK = int(os.environ.get('TLDR_NETWORK_ENABLED', '1')) > 0
3535
USE_CACHE = int(os.environ.get('TLDR_CACHE_ENABLED', '1')) > 0
3636
MAX_CACHE_AGE = int(os.environ.get('TLDR_CACHE_MAX_AGE', 24*7))
37+
CAFILE = None if os.environ.get('TLDR_CERT', None) is None else \
38+
Path(os.environ.get('TLDR_CERT')).expanduser()
3739

3840
URLOPEN_CONTEXT = None
3941
if int(os.environ.get('TLDR_ALLOW_INSECURE', '0')) == 1:
4042
URLOPEN_CONTEXT = ssl.create_default_context()
4143
URLOPEN_CONTEXT.check_hostname = False
4244
URLOPEN_CONTEXT.verify_mode = ssl.CERT_NONE
45+
elif CAFILE:
46+
URLOPEN_CONTEXT = ssl.create_default_context(cafile=CAFILE)
4347

4448
OS_DIRECTORIES = {
4549
"android": "android",

0 commit comments

Comments
 (0)