Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

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

Ognjen Francuski765e020e75e6
diff --git a/litellm/__init__.py b/litellm/__init__.py
index 6c7529477f5..80e76c2efa1 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -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 = {}
diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.py
index 1828a92d2eb..1b3ad5e35e1 100644
--- a/litellm/llms/custom_httpx/http_handler.py
+++ b/litellm/llms/custom_httpx/http_handler.py
@@ -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