fix: patch ssl.load_default_certs to handle corrupted Windows cert store
OpenSSL 3.x + corrupted Windows cert store causes aiohttp to crash at import time. Monkey-patch ssl.SSLContext.load_default_certs to fall back to certifi when Windows store fails.
This commit is contained in:
+17
@@ -10,6 +10,23 @@ if sys.platform == "win32":
|
||||
if os.path.isdir(_d):
|
||||
os.add_dll_directory(_d)
|
||||
|
||||
# Fix: OpenSSL 3.x + corrupted Windows cert store causes aiohttp to crash at import time.
|
||||
# Monkey-patch ssl.create_default_context to skip Windows cert store loading.
|
||||
if sys.platform == "win32":
|
||||
import ssl
|
||||
_orig_load_default_certs = ssl.SSLContext.load_default_certs
|
||||
def _safe_load_default_certs(self, purpose=ssl.Purpose.CLIENT_AUTH):
|
||||
try:
|
||||
_orig_load_default_certs(self, purpose)
|
||||
except ssl.SSLError:
|
||||
# Windows cert store is corrupted, use certifi instead
|
||||
try:
|
||||
import certifi
|
||||
self.load_verify_locations(certifi.where())
|
||||
except Exception:
|
||||
pass # No certs available, continue without verification
|
||||
ssl.SSLContext.load_default_certs = _safe_load_default_certs
|
||||
|
||||
from dataclasses import dataclass
|
||||
from input_layer import keyboard
|
||||
from beautifultable import BeautifulTable
|
||||
|
||||
Reference in New Issue
Block a user