Commit 9f8b923a authored by Manuel's avatar Manuel

restGateway: added SSL certificate to Flask config

certificates itself are ignored for safety reasons
parent 2cfcbf6a
...@@ -4,3 +4,9 @@ ...@@ -4,3 +4,9 @@
*.log *.log
**/env **/env
**/venv **/venv
src/modules/certificate/articonf1.key
src/modules/certificate/articonf1.crt
src/modules/certificate/articonf1-chain.crt
...@@ -18,15 +18,20 @@ LOGGER = logging.getLogger(__name__) ...@@ -18,15 +18,20 @@ LOGGER = logging.getLogger(__name__)
################################# #################################
import connexion import connexion
# load swagger config
def get_bundled_specs(main_file: Path) -> Dict[str, Any]: def get_bundled_specs(main_file: Path) -> Dict[str, Any]:
'''
parses the given swagger.yml file and resolves dependencies
from that file to enable the possibility to split the
configuration into several files
'''
parser = prance.ResolvingParser(str(main_file.absolute()), parser = prance.ResolvingParser(str(main_file.absolute()),
lazy = True, backend = 'openapi-spec-validator') lazy = True, backend = 'openapi-spec-validator')
parser.parse() parser.parse()
return parser.specification return parser.specification
# load swagger config
app = connexion.App(__name__, specification_dir='configs/') app = connexion.App(__name__, specification_dir='configs/')
# app.add_api('swagger.yml')
app.add_api(get_bundled_specs(Path("configs/swagger.yml")), app.add_api(get_bundled_specs(Path("configs/swagger.yml")),
resolver = connexion.RestyResolver("cms_rest_api")) resolver = connexion.RestyResolver("cms_rest_api"))
...@@ -35,6 +40,12 @@ app.add_api(get_bundled_specs(Path("configs/swagger.yml")), ...@@ -35,6 +40,12 @@ app.add_api(get_bundled_specs(Path("configs/swagger.yml")),
def api_root(): def api_root():
return 'Endpoint of SMART RESTful API Gateway!' return 'Endpoint of SMART RESTful API Gateway!'
# SSL configuration
context = ('../../modules/certificate/articonf1.crt', '../../modules/certificate/articonf1.key') # certificate and key files
# start app # start app
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=False) # disable reloader so only subscribed once to rabbitmq
\ No newline at end of file # app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=False) # disable reloader so only subscribed once to rabbitmq
app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=False, ssl_context=context) # disable reloader so only subscribed once to rabbitmq
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment