From 2c1984f0714015d46f37b5425e8ab96dec651c3d Mon Sep 17 00:00:00 2001 From: Flowseal Date: Mon, 23 Nov 2026 07:36:05 +0300 Subject: [PATCH] #1632 create_ssl_context ca reorder --- proxy/utils.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/proxy/utils.py b/proxy/utils.py index 6e703b9..96bbb48 100644 --- a/proxy/utils.py +++ b/proxy/utils.py @@ -151,11 +151,16 @@ def set_x25519(context: ssl.SSLContext) -> None: def create_ssl_context(*, check_hostname: bool = True) -> ssl.SSLContext: + context = ssl.create_default_context() + bundle_dir = getattr(sys, '_MEIPASS', None) - cafile = (os.path.join(bundle_dir, 'certifi', 'cacert.pem') - if bundle_dir else certifi.where()) - context = ssl.create_default_context(cafile=cafile) - context.load_default_certs() + try: + cafile = (os.path.join(bundle_dir, 'certifi', 'cacert.pem') + if bundle_dir else certifi.where()) + context.load_verify_locations(cafile=cafile) + except Exception: + pass + set_x25519(context) context.check_hostname = check_hostname return context