Skip to content

pgwire-common: wrap TLS connections in a backend-neutral TlsStream - #39433

Open
jasonhernandez wants to merge 1 commit into
mainfrom
jason/tls-stack-5-tlsstream-bridge
Open

jasonhernandez wants to merge 1 commit into
mainfrom
jason/tls-stack-5-tlsstream-bridge

Conversation

@jasonhernandez

@jasonhernandez jasonhernandez commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

pgwire and balancerd now pass TLS connections around as Conn::Ssl(TlsStream), a backend-neutral stream, instead of an OpenSSL SslStream. This lets each accept and dial path move to rustls independently. Part of the TLS stack moving off OpenSSL.

Description

  • Add mz_pgwire_common::TlsStream with Openssl, rustls Server and rustls Client variants, implementing get_ref, get_mut, AsyncRead, AsyncWrite and AsyncReady.
  • SNI lookup moves behind TlsStream::server_name, which balancerd's pgwire resolver uses instead of querying the OpenSSL session directly.
  • pgwire and balancerd wrap their existing OpenSSL streams in TlsStream::Openssl.
  • Add tokio-rustls to the workspace. The lockfile gains only dependency edges.

Risks

No behavior change: nothing constructs the rustls variants yet, and the OpenSSL variant makes the same calls as before, including for SNI.

Tests

No new tests. The existing balancerd server integration tests cover the SNI and TLS accept paths.

🤖 Generated with Claude Code

`Conn::Ssl` now holds a `TlsStream` enum with an `Openssl` variant and
rustls `Server` and `Client` variants. SNI lookup moves behind
`TlsStream::server_name`, so balancerd's resolver no longer reaches into
the OpenSSL session directly.

pgwire and balancerd wrap their existing OpenSSL streams in
`TlsStream::Openssl`. Nothing constructs the rustls variants yet, so TLS
behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jasonhernandez
jasonhernandez force-pushed the jason/tls-stack-5-tlsstream-bridge branch from f6e14c9 to 926248f Compare October 27, 2026 07:09
jasonhernandez added a commit that referenced this pull request Oct 27, 2026
### Motivation

First PR in the TLS migration stack replacing #36085: #39428 (this,
OpenSSL handshake tests) → #39430 (rustls Postgres connector) → #39431
(channel binding) and #39432 (nightly public-CA check). #39433
(pgwire-common `TlsStream` bridge) is independent, based on main.

These tests pin down today's OpenSSL TLS client behavior in
`mz-tls-util` ahead of the rustls migration, which will extend each test
with a rustls leg. Split out of #36085.

### Description

- `verify_full_trusts_default_store`: with `sslmode=verify-full` and no
`sslrootcert`, `make_tls` trusts a CA from the default store
(`SSL_CERT_FILE`).
- `client_certs_accepted`: `make_tls` presents the configured client
certificate to a server that requires one.
- Harness: a throwaway `TestCa`, a blocking OpenSSL `SslAcceptor` server
on a background thread, and connect/assert helpers.
- `tempfile` and `tokio` added as dev-dependencies (both existing
workspace deps). No production code changes.

### Verification

Ran the tests repeatedly under nextest. Confirmed each fails when its
property is broken (no `SSL_CERT_FILE`, no client cert).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Jason Hernandez <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@jasonhernandez
jasonhernandez marked this pull request as ready for review October 28, 2026 06:22
@jasonhernandez
jasonhernandez requested a review from a team as a code owner October 28, 2026 06:22

This branch has not been deployed

No deployments
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.

2 participants