pingora
pingora copied to clipboard
feat(tls): add SNI to SslDigest for HTTP filter access
This PR adds the SNI (Server Name Indication) to the SslDigest struct, addressing the request in #547 to make SNI accessible in the HTTP filter context.
The implementation follows the approach suggested in the issue comments by @pszabop. When using boringssl or openssl, the SNI is extracted from the SSL connection during handshake and stored in SslDigest. This allows users to access it in their request_filter callback:
async fn request_filter(&self, session: &mut Session, ctx: &mut Self::CTX) -> Result<bool> {
if let Some(digest) = session.digest() {
if let Some(ssl_digest) = &digest.ssl_digest {
if let Some(sni) = &ssl_digest.sni {
// Compare with HTTP Host header, route based on SNI, etc.
}
}
}
Ok(false)
}
The rustls and s2n backends currently pass None for SNI. Extending those backends can be done in follow-up work.
Fixes #547