Skip to content

Add an async SNI example - #204

Merged
abs0luty merged 1 commit into
masterfrom
example/async-sni
Nov 10, 2026
Merged

abs0luty merged 1 commit into
masterfrom
example/async-sni

Conversation

@abs0luty

@abs0luty abs0luty commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds examples/async_sni.rs, which resolves a TLS certificate asynchronously from the server name in the ClientHello, after the ClientHello is read but before the rest of the handshake. No library code changes.

This answers the request in the tracked issue (#85). The built-in RustlsAcceptor picks one ServerConfig up front, and RustlsConfig::from_sni_pem_files (0.9.0) covers a map of known hostnames, but a resolver that has to await — a database, a secret manager, an ACME directory — needs tokio_rustls::LazyConfigAcceptor inside a custom Accept impl. That path exists today but was undocumented.

Show how to resolve a TLS certificate asynchronously from the ClientHello
with `LazyConfigAcceptor` and a custom `Accept` implementation. The built-in
acceptor picks one config up front and `from_sni_pem_files` covers a known
hostname map, but a resolver that has to await needs this pattern.

The example shares one deadline across the ClientHello read and the
handshake, sets ALPN through `RustlsConfig::from_pem_file`, and rejects
unknown or missing server names.
@abs0luty
abs0luty merged commit 63db627 into master Nov 10, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant