# tls

URL: /pounce/api/net/tls/
Section: net
Description: TLS context creation for pounce.

Creates and configures ``ssl.SSLContext`` from ``ServerConfig`` fields.
Uses stdlib ``ssl`` with secure defaults (TLSv1.2+, no compression,
cipher order honoured).  Optionally uses ``truststore`` (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.

---

> For a complete page index, fetch /pounce/llms.txt.

Open LLM text
(/pounce/api/net/tls/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fnet%2Ftls%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fnet%2Ftls%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fnet%2Ftls%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fnet%2Ftls%2Findex.txt)

Module

#
`net.tls`

TLS context creation for pounce.

Creates and configures`ssl.SSLContext` from `ServerConfig`fields.
Uses stdlib`ssl`with secure defaults (TLSv1.2+, no compression,
cipher order honoured). Optionally uses`truststore`(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.

3Functions

## 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 (/pounce/api/config/#ServerConfig)`

Server configuration with`ssl_certfile` and `ssl_keyfile`set.

##### 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` (/pounce/api/protocols/h2/) first
(preferred), then`http/1.1`as fallback. Otherwise advertise only
`http/1.1`so 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 (/pounce/api/config/#ServerConfig)`

##### Returns

`bool`
