Repository navigation
Add support for client-side direct TLS - #1359
Conversation
|
~Converting to draft since there are some build failures. ~ EDIT: This is ready for review. |
| int verify_depth; | ||
| int verify_name; | ||
| int verify_time; | ||
| struct tls_alpn_config *alpn_config; |
There was a problem hiding this comment.
Instead of making an abstraction to configure this, how about we just hardcode the postgres ALPN support? Now that we have libusual being part of pgbouncer, I think it makes sense to couple them a bit more tightly in cases where we don't need abstractions.
There was a problem hiding this comment.
Good idea. That simplifies things considerably. Done.
|
|
||
| static ssize_t tls_sbufio_peek(struct SBuf *sbuf, void *buf, size_t len) | ||
| { | ||
| /* unused */ |
| int | ||
| alpn_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen, | ||
| const unsigned char *in, unsigned int inlen, void *userdata); |
There was a problem hiding this comment.
This definition is not necessary. I guess you added it because there was a warning. Let's just define the function as static.
| client_accept_base = NULL; | ||
| } | ||
|
|
||
| static bool handle_tls_startup(SBuf *sbuf, bool is_unix) |
There was a problem hiding this comment.
| static bool handle_tls_startup(SBuf *sbuf, bool is_unix) | |
| static bool handle_possible_direct_tls_startup(SBuf *sbuf, bool is_unix) |
| return sbuf_use_callback_once(sbuf, EV_READ, sbuf_tls_startup_cb); | ||
| } | ||
|
|
||
| static void sbuf_tls_startup_cb(evutil_socket_t fd, short flags, void *_sbuf) |
There was a problem hiding this comment.
| static void sbuf_tls_startup_cb(evutil_socket_t fd, short flags, void *_sbuf) | |
| static void sbuf_possible_direct_tls_startup_cb(evutil_socket_t fd, short flags, void *_sbuf) |
This commit allows clients to connect to pgbouncer using libpq's sslnegotiation=direct introduced in Postgres 17. At a high level, this commit: - Uses a new API in libusual to configure the Postgres ALPN (i.e., postgresql) as part of the TLS config when server_tls_sslmode is enabled. - Checks if the first byte of a connection is a TLS handshake, and if it is, proceeded to do a TLS handshake directly. Fixes #1203
Just hardcode the Postgres ALPN now that libusual is a part of pgbouncer. Also, address other PR comments.
- Rename functions for direct TLS support - Use static and remove function prototype
|
@JelteF I missed a spot in the rename but have fixed it now. |
This commit allows clients to connect to pgbouncer using libpq's sslnegotiation=direct introduced in Postgres 17.
At a high level, this commit:
Fixes #1203