Add conditional SSL bypass for on-prem vLLM endpoints#108
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an opt-in SSL verification bypass for OpenAI-compatible endpoints (notably on-prem vLLM with self-signed certs) by changing global HTTPS verification behavior when OPENAI_SSL_VERIFY=0 is set, aiming to prevent TLS failures in the OpenAI SDK/httpx stack.
Changes:
- Adds a global SSL “verify off” switch controlled by
OPENAI_SSL_VERIFY=0. - Overrides Python’s default HTTPS context to an unverified context when enabled.
- Monkey-patches
httpx.Client/httpx.AsyncClientto default toverify=Falsewhen enabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+8
to
+11
| # Global SSL bypass — runs at plugin load time, before any provider client | ||
| # is constructed. Covers both sync (httpx.Client) and async | ||
| # (httpx.AsyncClient) paths used by the OpenAI SDK. | ||
| # Only active when OPENAI_SSL_VERIFY=0 is set in the environment. |
Comment on lines
+19
to
+35
| import httpx as _httpx | ||
|
|
||
| _OriginalClient = _httpx.Client | ||
| _OriginalAsyncClient = _httpx.AsyncClient | ||
|
|
||
| class _UnverifiedClient(_OriginalClient): | ||
| def __init__(self, *args, **kwargs): | ||
| kwargs.setdefault("verify", False) | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| class _UnverifiedAsyncClient(_OriginalAsyncClient): | ||
| def __init__(self, *args, **kwargs): | ||
| kwargs.setdefault("verify", False) | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| _httpx.Client = _UnverifiedClient | ||
| _httpx.AsyncClient = _UnverifiedAsyncClient |
Comment on lines
+16
to
+18
| if _os.environ.get("OPENAI_SSL_VERIFY", "1").strip() == "0": | ||
| _ssl._create_default_https_context = _ssl._create_unverified_context # noqa: SLF001 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add conditional SSL bypass for on-prem vLLM endpoints
On-premises vLLM deployments commonly use self-signed certificates that
cause SSL verification failures in both the OpenAI SDK and the underlying
httpx transport layer. This change introduces an opt-in bypass controlled
by the OPENAI_SSL_VERIFY environment variable.
When OPENAI_SSL_VERIFY=0 is set:
any standard library consumers (urllib, etc.)
that default verify=False, covering the OpenAI SDK's sync and async
transport paths.
No behaviour change when the environment variable is absent or set to
any value other than 0.
Testing
Verified against an on-prem vLLM instance with a self-signed certificate
using both the chat and completions endpoints.
Notes
This bypass is intended for internal/development environments only and
should never be enabled in production against public endpoints.