From 8d7596125161bea13641644fca2384411e00a4e5 Mon Sep 17 00:00:00 2001 From: gaoruoshu Date: Tue, 15 Feb 2022 17:03:40 +0800 Subject: [PATCH] check whether the certificate file exists --- analysis/app.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/analysis/app.py b/analysis/app.py index 31b5f51..b25e784 100644 --- a/analysis/app.py +++ b/analysis/app.py @@ -22,6 +22,8 @@ from logging.handlers import SysLogHandler from flask import Flask from flask_restful import Api +LOGGER = logging.getLogger(__name__) + class App: """flask application""" @@ -51,6 +51,9 @@ class App: def startup_app(self, host, port, tls, cert_file, key_file, ca_file, log_level): """start flask app""" + if not os.path.exists(cert_file) or not os.path.exists(key_file) or not os.path.exists(ca_file): + LOGGER.error("Startup failed. Please provide the authentication certificate.") + raise FileNotFoundError("Startup failed. Please provide the authentication certificate.") level = logging.getLevelName(log_level.upper()) self.config_log(level) self.add_resource() -- 2.30.0