From 30879312326e4e0ac9c285c7db55b5c3c6f0e491 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 23 Apr 2024 12:39:27 +0300 Subject: Don't fail startup due to missing config. --- gn2/wqflask/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gn2') diff --git a/gn2/wqflask/__init__.py b/gn2/wqflask/__init__.py index f6e9ef53..c77895c1 100644 --- a/gn2/wqflask/__init__.py +++ b/gn2/wqflask/__init__.py @@ -2,6 +2,7 @@ # pylint: disable=C0413,E0611 import os import time +import logging import datetime from typing import Tuple from pathlib import Path @@ -56,8 +57,13 @@ def numcoll(): def parse_ssl_key(app: Flask, keyconfig: str): """Parse key file paths into objects""" - with open(app.config[keyconfig]) as _sslkey: - app.config[keyconfig] = JsonWebKey.import_key(_sslkey.read()) + keypath = app.config.get(keyconfig, "").strip() + if not bool(keypath): + logging.error(f"Expected configuration '{keyconfig}'") + return + + with open(keypath) as _sslkey: + app.config[keyconfig] = JsonWebKey.import_key(_sslkey.read()) -- cgit v1.2.3