-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying a certificate bundle with TLDR_CERT #243
base: main
Are you sure you want to change the base?
Conversation
Setting TLDR_CERT will use that as the certificate bundle for updates
@@ -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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() |
This change should fix the error when $TLDR_CERT is not set. Also, we prefer to use pathlib
instead of os.path
.
|
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this method accepts a path argument or it will need str(CAFILE)
This pull request makes it possible to specificy a different certificate store/bundle by setting:
TLDR_CERT=/path/to/certificates.crt
This is a more secure alternative to disabling SSL verification entirely when behind an SSL proxy.