Skip to content

Add conditional SSL bypass for on-prem vLLM endpoints#108

Merged
giswqs merged 2 commits into
opengeos:mainfrom
dmartinez05:patch-1
Jun 2, 2026
Merged

Add conditional SSL bypass for on-prem vLLM endpoints#108
giswqs merged 2 commits into
opengeos:mainfrom
dmartinez05:patch-1

Conversation

@dmartinez05

Copy link
Copy Markdown
Contributor

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:

  • The default SSL context is replaced with an unverified one, covering
    any standard library consumers (urllib, etc.)
  • httpx.Client and httpx.AsyncClient are monkey-patched with subclasses
    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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.AsyncClient to default to verify=False when 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

@giswqs giswqs merged commit c2033ed into opengeos:main Jun 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants