Skip to content

Commit

Permalink
fix: add ssl_context in res fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Nov 8, 2024
1 parent d298b5e commit ca355f5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion avilla/elizabeth/perform/resource_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ElizabethResource,
ElizabethVoiceResource,
)
from avilla.standard.qq.util import ssl_ctx

if TYPE_CHECKING:
from avilla.elizabeth.protocol import ElizabethProtocol # noqa
Expand All @@ -28,5 +29,5 @@ async def fetch_resource(self, resource: ElizabethResource) -> bytes:
if resource.url is None:
raise UnknownTarget
async with ClientSession() as session:
async with session.get(resource.url) as resp:
async with session.get(resource.url, ssl=ssl_ctx) as resp:
return await resp.read()
3 changes: 2 additions & 1 deletion avilla/onebot/v11/perform/resource_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
OneBot11Resource,
OneBot11VideoResource,
)
from avilla.standard.qq.util import ssl_ctx

if TYPE_CHECKING:
from avilla.onebot.v11.protocol import OneBot11Protocol # noqa
Expand All @@ -28,5 +29,5 @@ class OneBot11ResourceFetchPerform((m := ProtocolCollector["OneBot11Protocol"]()
@m.entity(CoreCapability.fetch, resource=OneBot11VideoResource)
async def fetch_resource(self, resource: OneBot11Resource) -> bytes:
async with ClientSession() as session:
async with session.get(resource.url) as resp:
async with session.get(resource.url, ssl=ssl_ctx) as resp:
return await resp.read()
4 changes: 4 additions & 0 deletions avilla/standard/qq/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ssl

ssl_ctx = ssl.create_default_context()
ssl_ctx.set_ciphers("DEFAULT")

0 comments on commit ca355f5

Please sign in to comment.