mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Allow using environment cacert file (#38816)
This commit is contained in:
parent
08d93b8349
commit
f207d46390
@ -1,4 +1,5 @@
|
||||
"""Helper to create SSL contexts."""
|
||||
from os import environ
|
||||
import ssl
|
||||
|
||||
import certifi
|
||||
@ -6,9 +7,12 @@ import certifi
|
||||
|
||||
def client_context() -> ssl.SSLContext:
|
||||
"""Return an SSL context for making requests."""
|
||||
context = ssl.create_default_context(
|
||||
purpose=ssl.Purpose.SERVER_AUTH, cafile=certifi.where()
|
||||
)
|
||||
|
||||
# Reuse environment variable definition from requests, since it's already a requirement
|
||||
# If the environment variable has no value, fall back to using certs from certifi package
|
||||
cafile = environ.get("REQUESTS_CA_BUNDLE", certifi.where())
|
||||
|
||||
context = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH, cafile=cafile)
|
||||
return context
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user