Allow users to set a combined certificte and key file for additional certificates in the SSL context

This commit is contained in:
Trenton H
2023-08-21 13:21:02 -07:00
parent d1ae82c5c2
commit 16adddc803
5 changed files with 83 additions and 7 deletions

View File

@@ -67,11 +67,20 @@ def __get_float(key: str, default: float) -> float:
return float(os.getenv(key, default))
def __get_path(key: str, default: Union[PathLike, str]) -> Path:
def __get_path(
key: str,
default: Optional[Union[PathLike, str]] = None,
) -> Optional[Path]:
"""
Return a normalized, absolute path based on the environment variable or a default
Return a normalized, absolute path based on the environment variable or a default,
if provided. If not set and no default, returns None
"""
return Path(os.environ.get(key, default)).resolve()
if key in os.environ:
return Path(os.environ[key]).resolve()
elif default is not None:
return Path(default).resolve()
else:
return None
def __get_list(
@@ -477,6 +486,8 @@ CSRF_COOKIE_NAME = f"{COOKIE_PREFIX}csrftoken"
SESSION_COOKIE_NAME = f"{COOKIE_PREFIX}sessionid"
LANGUAGE_COOKIE_NAME = f"{COOKIE_PREFIX}django_language"
EMAIL_CERTIFICATE_FILE = __get_path("PAPERLESS_EMAIL_CERTIFICATE_FILE")
###############################################################################
# Database #