From d89c0a2626632b9fb8da8931ce7f5b46663a6ccf Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Thu, 7 Oct 2021 17:18:55 +0200 Subject: [PATCH] setup the structure to use ssl --- src/kassandra/webhook.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kassandra/webhook.py b/src/kassandra/webhook.py index efa71ac..d0c70c4 100644 --- a/src/kassandra/webhook.py +++ b/src/kassandra/webhook.py @@ -5,6 +5,7 @@ The webhook receiving the alerts from alertmanager. import asyncio import aiohttp.web import aiohttp.web_request +import ssl from typing import ( Any, @@ -12,6 +13,9 @@ from typing import ( ) from .config import Config +def load_ssl_context(config:Config)->ssl.SSLContext: + pass + async def run_webhook( alert_queue: asyncio.Queue[dict[str, Any]], config: Config @@ -29,5 +33,8 @@ async def run_webhook( app.add_routes([aiohttp.web.post(config.endpoint, handler)]) runner = aiohttp.web.AppRunner(app) await runner.setup() - site = aiohttp.web.TCPSite(runner, config.host, config.port) + ssl_context = None + if config.tls: + ssl_context = load_ssl_context(config) + site = aiohttp.web.TCPSite(runner, config.host, config.port, ssl_context=ssl_context) await site.start()