From 6b0f04419821af7fa5d9ab512548acdb7bf02b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E8=8B=B7=E6=99=B6?= <2749332490@qq.com> Date: Mon, 24 Mar 2025 13:20:05 +0800 Subject: [PATCH] fix: fix other errors --- astrbot/core/utils/t2i/local_strategy.py | 5 ++++- astrbot/core/utils/t2i/network_strategy.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/astrbot/core/utils/t2i/local_strategy.py b/astrbot/core/utils/t2i/local_strategy.py index 23abba6e6..ccd0da0fc 100644 --- a/astrbot/core/utils/t2i/local_strategy.py +++ b/astrbot/core/utils/t2i/local_strategy.py @@ -1,5 +1,6 @@ import re import aiohttp +import ssl, certifi from io import BytesIO from . import RenderStrategy @@ -91,7 +92,9 @@ class LocalRenderStrategy(RenderStrategy): try: image_url = re.findall(IMAGE_REGEX, line)[0] print(image_url) - async with aiohttp.ClientSession(trust_env=True) as session: + ssl_context = ssl.create_default_context(cafile=certifi.where()) + connector = aiohttp.TCPConnector(ssl=ssl_context) + async with aiohttp.ClientSession(trust_env=True, connector=connector) as session: async with session.get(image_url) as resp: image_res = Image.open(BytesIO(await resp.read())) images[i] = image_res diff --git a/astrbot/core/utils/t2i/network_strategy.py b/astrbot/core/utils/t2i/network_strategy.py index b9b9abffe..72a5ecf48 100644 --- a/astrbot/core/utils/t2i/network_strategy.py +++ b/astrbot/core/utils/t2i/network_strategy.py @@ -1,5 +1,6 @@ import aiohttp import os +import ssl, certifi from . import RenderStrategy from astrbot.core.config import VERSION @@ -46,7 +47,9 @@ class NetworkRenderStrategy(RenderStrategy): }, } if return_url: - async with aiohttp.ClientSession(trust_env=True) as session: + ssl_context = ssl.create_default_context(cafile=certifi.where()) + connector = aiohttp.TCPConnector(ssl=ssl_context) + async with aiohttp.ClientSession(trust_env=True, connector=connector) as session: async with session.post( f"{self.BASE_RENDER_URL}/generate", json=post_data ) as resp: