Skip to content

Add Acceptor::from_server_config for runtime-built rustls ServerConfig - #942

Open
torinnd wants to merge 1 commit into
cloudflare:mainfrom
torinnd:acceptor-from-server-config
Open

Add Acceptor::from_server_config for runtime-built rustls ServerConfig#942
torinnd wants to merge 1 commit into
cloudflare:mainfrom
torinnd:acceptor-from-server-config

Conversation

@torinnd

@torinnd torinnd commented Jul 27, 2026

Copy link
Copy Markdown

Fixes #916

Implements the constructor proposed in #916: Acceptor::from_server_config(Arc). It performs the same construction TlsSettings::build() already does in its final step ( RusTlsAcceptor::from(...)), taking the config as an argument instead of loading certificate and key files. No existing behavior changes, and callbacks: None and offload: None match what build() produces today with no callbacks or handshake offload configured.

Includes a test that builds a ServerConfig by hand, constructs an Acceptor from it, and completes a TLS handshake and HTTP round trip by driving tls_handshake() directly on an accepted TCP stream, with no TlsSettings involved and no certificate files in the handshake path. The test binds port 0 so it runs in constrained environments.

Acceptor::tls_handshake() is public, but an Acceptor could previously
only be obtained via TlsSettings::build(), which loads certificates and
key from files on disk. Add a constructor taking an already-built
rustls ServerConfig, supporting configurations whose key material lives
in memory (e.g. fetched from a secrets manager) without writing private
keys to disk.

This is the same construction TlsSettings::build() already performs in
its final step, so no existing behavior changes.
@torinnd
torinnd force-pushed the acceptor-from-server-config branch from 0f59f33 to 896d90f Compare July 28, 2026 09:20
@drcaramelsyrup drcaramelsyrup added the ergonomics Ease of use, developer friendliness label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ergonomics Ease of use, developer friendliness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose Acceptor constructors for in-memory rustls configs (ServerConfig / TlsAcceptor)

2 participants