mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Fix ssl context being recreated frequently in httpx (#89932)
* Fix ssl context being created every time in httpx * its expensive, only do it once
This commit is contained in:
@@ -16,6 +16,15 @@ def client_context() -> ssl.SSLContext:
|
||||
return ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH, cafile=cafile)
|
||||
|
||||
|
||||
# Create this only once and reuse it
|
||||
_DEFAULT_SSL_CONTEXT = client_context()
|
||||
|
||||
|
||||
def get_default_context() -> ssl.SSLContext:
|
||||
"""Return the default SSL context."""
|
||||
return _DEFAULT_SSL_CONTEXT
|
||||
|
||||
|
||||
def server_context_modern() -> ssl.SSLContext:
|
||||
"""Return an SSL context following the Mozilla recommendations.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user