mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-10-31 00:06:59 +03:00
Restore win7 compatability
This commit is contained in:
1 parent
73aa394d9a
commit
dc2c4c03f6
2 files changed
+10
-2
No files matched your search
+2
-1
@@ -12,6 +12,7 @@ import logging
|
||||
|
||||
from typing import Dict, FrozenSet, NamedTuple, Optional, Tuple
|
||||
from .stats import stats
|
||||
from .utils import set_x25519
|
||||
|
||||
try:
|
||||
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
|
||||
@@ -272,7 +273,7 @@ async def probe_appdata_len(domain: str, port: int = 443,
|
||||
writer = None
|
||||
try:
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.set_ecdh_curve('X25519')
|
||||
set_x25519(ctx)
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
ctx.minimum_version = ssl.TLSVersion.TLSv1_3
|
||||
|
||||
+8
-1
@@ -143,13 +143,20 @@ class _PinnedHTTPSHandler(urllib.request.HTTPSHandler):
|
||||
return super().https_open(req)
|
||||
|
||||
|
||||
def set_x25519(context: ssl.SSLContext) -> None:
|
||||
try:
|
||||
context.set_ecdh_curve('X25519')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def create_ssl_context(*, check_hostname: bool = True) -> ssl.SSLContext:
|
||||
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()
|
||||
context.set_ecdh_curve('X25519')
|
||||
set_x25519(context)
|
||||
context.check_hostname = check_hostname
|
||||
return context
|
||||
|
||||
|
||||
Reference in new issue
Block a user