Module

net.tls

TLS context creation for pounce.

Creates and configuresssl.SSLContext from ServerConfigfields. Uses stdlibsslwith secure defaults (TLSv1.2+, no compression, cipher order honoured). Optionally usestruststore(via bengal-pounce[tls]) for system certificate store integration.

ALPN protocols are advertised so HTTP/2 negotiation works when the h2 protocol handler is available.

Functions

create_tls_context 1 ssl.SSLContext
Build an ``ssl.SSLContext`` from server configuration.
def create_tls_context(config: ServerConfig) -> ssl.SSLContext
Parameters
Name Type Description
config ServerConfig

Server configuration withssl_certfile and ssl_keyfileset.

Returns
ssl.SSLContext
_build_alpn_protocols 1 list[str]
Return the ALPN protocol list based on available optional deps. If HTTP/2 is e…
def _build_alpn_protocols(*, http2_enabled: bool = True) -> list[str]

Return the ALPN protocol list based on available optional deps.

If HTTP/2 is enabled and h2 is installed, advertise h2 first (preferred), thenhttp/1.1as fallback. Otherwise advertise only http/1.1so operators can force H1 at the origin.

Parameters
Name Type Description
http2_enabled bool Default:True
Returns
list[str]
is_tls_configured 1 bool
Return True if TLS is configured in the server config.
def is_tls_configured(config: ServerConfig) -> bool
Parameters
Name Type Description
config ServerConfig
Returns
bool