add ciphers in command and pass to hypercorn for proxy (#11916)

Signed-off-by: frankzye1 <frankzye@qq.com>
This commit is contained in:
frank 2025-06-21 05:45:48 +08:00 committed by GitHub
parent c36d0f667b
commit 0d486120bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -147,6 +147,7 @@ class ProxyInitializationHelpers:
port: int,
ssl_certfile_path: str,
ssl_keyfile_path: str,
ciphers: Optional[str] = None,
):
"""
Initialize litellm with `hypercorn`
@ -168,6 +169,8 @@ class ProxyInitializationHelpers:
)
config.certfile = ssl_certfile_path
config.keyfile = ssl_keyfile_path
if ciphers is not None:
config.ciphers = ciphers
# hypercorn serve raises a type warning when passing a fast api app - even though fast API is a valid type
asyncio.run(serve(app, config)) # type: ignore
@ -455,6 +458,12 @@ class ProxyInitializationHelpers:
help="Path to the SSL certfile. Use this when you want to provide SSL certificate when starting proxy",
envvar="SSL_CERTFILE_PATH",
)
@click.option(
"--ciphers",
default=None,
type=str,
help="Ciphers to use for the SSL setup.",
)
@click.option(
"--use_prisma_migrate",
is_flag=True,
@ -508,6 +517,7 @@ def run_server( # noqa: PLR0915
run_hypercorn,
ssl_keyfile_path,
ssl_certfile_path,
ciphers,
log_config,
use_prisma_migrate,
skip_server_startup,
@ -819,6 +829,7 @@ def run_server( # noqa: PLR0915
port=port,
ssl_certfile_path=ssl_certfile_path,
ssl_keyfile_path=ssl_keyfile_path,
ciphers=ciphers,
)

View File

@ -121,7 +121,7 @@ class TestProxyInitializationHelpers:
# Execute
ProxyInitializationHelpers._init_hypercorn_server(
mock_app, "localhost", 8000, None, None
mock_app, "localhost", 8000, None, None, None
)
# Assert
@ -129,7 +129,7 @@ class TestProxyInitializationHelpers:
# Test with SSL
ProxyInitializationHelpers._init_hypercorn_server(
mock_app, "localhost", 8000, "cert.pem", "key.pem"
mock_app, "localhost", 8000, "cert.pem", "key.pem", "ECDHE"
)
@patch("subprocess.Popen")