Expose the downstream socket fd to the TLS certificate callback#915
Expose the downstream socket fd to the TLS certificate callback#915rzvncj wants to merge 1 commit into
Conversation
The async `certificate_callback` only receives `&mut SslRef`, with no handle to the underlying connection. Applications that select or forge a leaf per connection sometimes need connection-level context that is only reachable from the socket fd, which is unavailable at certificate-selection time. `handshake_with_callback` already holds the stream when it pauses the handshake to invoke the callback, so capture the stream's fd and stash it on the SSL via `ex_data` just before the call. Add `set_downstream_fd` / `get_downstream_fd` helpers to the ext module of both openssl-derived backends -- the shared `boringssl_openssl` server path compiles against either, so both must carry the helper. The fd is stored as the same platform-conditional type as pingora-core's `UniqueIDType` (`RawFd` on unix, socket handle on Windows), so the call site passes `io.id()` through with no cast or truncation. No public trait signatures change; the rustls and s2n backends are untouched.
02bd02a to
9371d2b
Compare
|
The assumption here was that we don't want to change the API at all. If changing the API is allowed, there's a much smaller change that can be made, by adding an extra parameter to Please let me know. Thanks! |
|
I don't mean to rush anyone, but I haven't contributed to Pingora before and I'm unsure of the PR review process. Is it OK to ping? 🙂 |
yea, it's ok to ping. I'll try to get to this soon, have been quite busy but things have cooled down a bit now. |
Thanks! Very much appreciated. |
The async
certificate_callbackonly receives&mut SslRef, with no handle to the underlying connection. Applications that select or forge a leaf per connection sometimes need connection-level context that is only reachable from the socket fd, which is unavailable at certificate-selection time.handshake_with_callbackalready holds the stream when it pauses the handshake to invoke the callback, so capture the stream's fd and stash it on the SSL viaex_datajust before the call. Addset_downstream_fd/get_downstream_fdhelpers to the ext module of both openssl-derived backends -- the sharedboringssl_opensslserver path compiles against either, so both must carry the helper. The fd is stored as the same platform-conditional type as pingora-core'sUniqueIDType(RawFdon unix, socket handle on Windows), so the call site passesio.id()through with no cast or truncation. No public trait signatures change; the rustls and s2n backends are untouched.