This commit is contained in:
Flowseal committed 2026-09-22 21:26:53 +03:00
1 parent 3d59c813aa
commit caa949bee0
3 files changed
+16 -12

No files matched your search

+9 -2
View File
@@ -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()))