Jelajahi Sumber

fix: make SSL verification async

Omar Aburub 4 bulan lalu
induk
melakukan
3bcf9a442a
1 mengubah file dengan 5 tambahan dan 3 penghapusan
  1. 5 3
      backend/open_webui/retrieval/web/utils.py

+ 5 - 3
backend/open_webui/retrieval/web/utils.py

@@ -16,6 +16,8 @@ from typing import (
     Union,
     Literal,
 )
+
+from fastapi.concurrency import run_in_threadpool
 import aiohttp
 import certifi
 import validators
@@ -142,13 +144,13 @@ class RateLimitMixin:
 
 
 class URLProcessingMixin:
-    def _verify_ssl_cert(self, url: str) -> bool:
+    async def _verify_ssl_cert(self, url: str) -> bool:
         """Verify SSL certificate for a URL."""
-        return verify_ssl_cert(url)
+        return await run_in_threadpool(verify_ssl_cert, url)
 
     async def _safe_process_url(self, url: str) -> bool:
         """Perform safety checks before processing a URL."""
-        if self.verify_ssl and not self._verify_ssl_cert(url):
+        if self.verify_ssl and not await self._verify_ssl_cert(url):
             raise ValueError(f"SSL certificate verification failed for {url}")
         await self._wait_for_rate_limit()
         return True