pingora icon indicating copy to clipboard operation
pingora copied to clipboard

feat(tls): add SNI to SslDigest for HTTP filter access

Open singhvishalkr opened this issue 6 months ago • 1 comments

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

singhvishalkr avatar May 16 '26 07:05 singhvishalkr