feat: allow a custom TLS certificate for Milvus connections (#32427)

Open WebUI could not connect to a Milvus server that uses a self-signed or company-issued TLS certificate, because there was no way to tell it which certificate to trust. The new MILVUS_SERVER_PEM_PATH setting takes the path to that certificate file and uses it for the Milvus connection, in both normal and multi-tenancy mode. Leaving it unset keeps the current behaviour.

Fixes #31632
This commit is contained in:
Classic298 2026-10-14 21:59:57 +02:00 • committed by GitHub
parent de446952c2
commit 3bc82bb2c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View file

@ -603,6 +603,7 @@ if VECTOR_DB == 'mariadb-vector':
MILVUS_URI = os.getenv('MILVUS_URI', f'{DATA_DIR}/vector_db/milvus.db')
MILVUS_DB = os.getenv('MILVUS_DB', 'default')
MILVUS_TOKEN = os.getenv('MILVUS_TOKEN', None)
MILVUS_SERVER_PEM_PATH = os.getenv('MILVUS_SERVER_PEM_PATH', '')
MILVUS_INDEX_TYPE = os.getenv('MILVUS_INDEX_TYPE', 'HNSW')
MILVUS_METRIC_TYPE = os.getenv('MILVUS_METRIC_TYPE', 'COSINE')
MILVUS_HNSW_M = int(os.getenv('MILVUS_HNSW_M', '16'))

View file

@ -17,6 +17,7 @@ from open_webui.config import (
MILVUS_INDEX_TYPE,
MILVUS_IVF_FLAT_NLIST,
MILVUS_METRIC_TYPE,
MILVUS_SERVER_PEM_PATH,
MILVUS_TOKEN,
MILVUS_URI,
)
@ -244,9 +245,11 @@ class MilvusClient(VectorDBBase):
def __init__(self):
self.collection_prefix = 'open_webui'
if MILVUS_TOKEN is None:
self.client = Client(uri=MILVUS_URI, db_name=MILVUS_DB)
self.client = Client(uri=MILVUS_URI, db_name=MILVUS_DB, server_pem_path=MILVUS_SERVER_PEM_PATH)
else:
self.client = Client(uri=MILVUS_URI, db_name=MILVUS_DB, token=MILVUS_TOKEN)
self.client = Client(
uri=MILVUS_URI, db_name=MILVUS_DB, token=MILVUS_TOKEN, server_pem_path=MILVUS_SERVER_PEM_PATH
)
if ENABLE_DB_MIGRATIONS:
collections = {
collection_name_full.removesuffix(BM25_STAGING_SUFFIX)

View file

@ -14,6 +14,7 @@ from open_webui.config import (
MILVUS_INDEX_TYPE,
MILVUS_IVF_FLAT_NLIST,
MILVUS_METRIC_TYPE,
MILVUS_SERVER_PEM_PATH,
MILVUS_TOKEN,
MILVUS_URI,
)
@ -76,7 +77,9 @@ class MilvusClient(VectorDBBase):
def __init__(self):
# Milvus collection names can only contain numbers, letters, and underscores.
self.collection_prefix = MILVUS_COLLECTION_PREFIX.replace('-', '_')
self.client = Client(uri=MILVUS_URI, token=MILVUS_TOKEN, db_name=MILVUS_DB)
self.client = Client(
uri=MILVUS_URI, token=MILVUS_TOKEN, db_name=MILVUS_DB, server_pem_path=MILVUS_SERVER_PEM_PATH
)
# Main collection types for multi-tenancy
self.MEMORY_COLLECTION = f'{self.collection_prefix}_memories'