mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-10-21 11:08:44 +00:00
1 parent
3d59c813aa
commit
caa949bee0
3 files changed
+16
-12
No files matched your search
+9
-2
@@ -140,6 +140,13 @@ class _PinnedHTTPSHandler(urllib.request.HTTPSHandler):
|
||||
return super().https_open(req)
|
||||
|
||||
|
||||
def build_github_opener() -> urllib.request.OpenerDirector:
|
||||
def create_ssl_context(*, check_hostname: bool = True) -> ssl.SSLContext:
|
||||
context = ssl.create_default_context(cafile=certifi.where())
|
||||
return urllib.request.build_opener(_PinnedHTTPSHandler(context=context))
|
||||
context.load_default_certs()
|
||||
context.check_hostname = check_hostname
|
||||
return context
|
||||
|
||||
|
||||
def build_github_opener() -> urllib.request.OpenerDirector:
|
||||
return urllib.request.build_opener(
|
||||
_PinnedHTTPSHandler(context=create_ssl_context()))
|
||||
Reference in new issue
Block a user