diff --git a/twitchio/web/aio_adapter.py b/twitchio/web/aio_adapter.py index 2dd26988..1d54ece0 100644 --- a/twitchio/web/aio_adapter.py +++ b/twitchio/web/aio_adapter.py @@ -43,6 +43,8 @@ if TYPE_CHECKING: + from ssl import SSLContext + from ..authentication import AuthorizationURLPayload, UserTokenPayload from ..client import Client @@ -101,6 +103,8 @@ class AiohttpAdapter(BaseAdapter, web.Application): An optional :class:`str` passed to use as the EventSub secret. It is recommended you pass this parameter when using an adapter for EventSub, as it will reset upon restarting otherwise. You can generate token safe secrets with the :mod:`secrets` module. + ssl_context: SSLContext | None + An optional :class:`SSLContext` passed to the adapter. If SSL is setup via a front-facing web server such as NGINX, you should leave this as None. Examples -------- @@ -139,6 +143,7 @@ def __init__( domain: str | None = None, eventsub_path: str | None = None, eventsub_secret: str | None = None, + ssl_context: SSLContext | None = None, ) -> None: super().__init__() self._runner: web.AppRunner | None = None @@ -160,6 +165,8 @@ def __init__( path: str = eventsub_path.removeprefix("/").removesuffix("/") if eventsub_path else "callback" self._eventsub_path: str = f"/{path}" + self._ssl_context: SSLContext | None = ssl_context + self._runner_task: asyncio.Task[None] | None = None self.startup = self.event_startup self.shutdown = self.event_shutdown @@ -210,7 +217,7 @@ async def run(self, host: str | None = None, port: int | None = None) -> None: self._runner = web.AppRunner(self, access_log=None, handle_signals=True) await self._runner.setup() - site: web.TCPSite = web.TCPSite(self._runner, host or self._host, port or self._port) + site: web.TCPSite = web.TCPSite(self._runner, host or self._host, port or self._port, ssl_context=self._ssl_context) self._runner_task = asyncio.create_task(site.start(), name=f"twitchio-web-adapter:{self.__class__.__qualname__}") async def eventsub_callback(self, request: web.Request) -> web.Response: