feat: add SNI field to SslDigest for HTTP filter context access#857
feat: add SNI field to SslDigest for HTTP filter context access#857nanookclaw wants to merge 2 commits intocloudflare:mainfrom
Conversation
Fixes cloudflare#547 Add sni: Option<String> to SslDigest struct so that the SNI can be retrieved from req_filter() callbacks via session.digest().ssl_digest.sni. The SNI is extracted during TLS handshake and stored alongside existing TLS connection metadata (cipher, version, organization, etc.) in the SslDigest struct. Supported across all TLS backends: - BoringSSL/OpenSSL: via ssl.servername(NameType::HOST_NAME) - Rustls: via session.server_name() - s2n: via conn.server_name() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Would 6ebc829 the extensible SslDigest also work for your purposes? |
|
Pushed the |
|
Good question. I looked at the extension mechanism from 6ebc829 — the That said, the extensible approach is the right long-term direction. For the SNI case specifically, a dedicated field is the cleanest fit because:
If the team prefers keeping the struct surface smaller and routing all new fields through the extension, I can rework this to use the extension — but that would require making |
|
Thanks for the review! I'll add a wildcard SNI test case to the directory — something like matching and confirming still passes while (missing subdomain) is rejected. Will push shortly. |
Summary
Fixes #547
Adds an
sni: Option<String>field toSslDigestso that the Server Name Indication can be retrieved fromreq_filter()callbacks viasession.digest().ssl_digest.sni.The SNI is extracted during TLS handshake and stored alongside existing TLS connection metadata (cipher, version, organization, etc.) in the
SslDigeststruct.Changes
digest.rs: Addsni: Option<String>field toSslDigeststruct and updatenew()constructorssl.servername(ssl::NameType::HOST_NAME).map(ToOwned::to_owned)infrom_ssl()server.server_name().map(ToOwned::to_owned)fromServerConnection(returnsNonefor client connections)conn.server_name().map(ToOwned::to_owned)from the s2nConnectionUsage
After this change, users can access the SNI in their HTTP filter callbacks:
This directly addresses the use case described in #547 where the SNI is needed alongside the HTTP HOST header in
req_filter()but is currently inaccessible.Testing
sniisOption<String>so existing code is unaffected