Update handling of 'litellm.ssl_verify' in HTTP handlers to allow for custom, self-signed certificates.

This commit is contained in:
Ognjen Francuski 2024-08-20 10:16:03 +02:00
parent e747127e3b
commit 765e020e75
2 changed files with 23 additions and 9 deletions

View file

@ -111,7 +111,7 @@ common_cloud_provider_auth_params: dict = {
"providers": ["vertex_ai", "bedrock", "watsonx", "azure", "vertex_ai_beta"],
}
use_client: bool = False
ssl_verify: bool = True
ssl_verify: Union[str, bool] = True
ssl_certificate: Optional[str] = None
disable_streaming_logging: bool = False
in_memory_llm_clients_cache: dict = {}

View file

@ -35,11 +35,18 @@ class AsyncHTTPHandler:
self, timeout: Optional[Union[float, httpx.Timeout]], concurrent_limit: int
) -> httpx.AsyncClient:
# Check if the HTTP_PROXY and HTTPS_PROXY environment variables are set and use them accordingly.
ssl_verify = bool(os.getenv("SSL_VERIFY", litellm.ssl_verify))
# SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts.
# /path/to/certificate.pem
ssl_verify = os.getenv(
"SSL_VERIFY",
litellm.ssl_verify
)
# An SSL certificate used by the requested host to authenticate the client.
# /path/to/client.pem
cert = os.getenv(
"SSL_CERTIFICATE", litellm.ssl_certificate
) # /path/to/client.pem
"SSL_CERTIFICATE",
litellm.ssl_certificate
)
if timeout is None:
timeout = _DEFAULT_TIMEOUT
@ -212,11 +219,18 @@ class HTTPHandler:
if timeout is None:
timeout = _DEFAULT_TIMEOUT
# Check if the HTTP_PROXY and HTTPS_PROXY environment variables are set and use them accordingly.
ssl_verify = bool(os.getenv("SSL_VERIFY", litellm.ssl_verify))
# SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts.
# /path/to/certificate.pem
ssl_verify = os.getenv(
"SSL_VERIFY",
litellm.ssl_verify
)
# An SSL certificate used by the requested host to authenticate the client.
# /path/to/client.pem
cert = os.getenv(
"SSL_CERTIFICATE", litellm.ssl_certificate
) # /path/to/client.pem
"SSL_CERTIFICATE",
litellm.ssl_certificate
)
if client is None:
# Create a client with a connection pool