Skip to content

Allow running tokio-postgres with rustls#426

Merged
jxs merged 9 commits intorust-db:mainfrom
tomasol:pr-rustls-postgres
Apr 27, 2026
Merged

Allow running tokio-postgres with rustls#426
jxs merged 9 commits intorust-db:mainfrom
tomasol:pr-rustls-postgres

Conversation

@tomasol
Copy link
Copy Markdown
Contributor

@tomasol tomasol commented Apr 22, 2026

This adds tokio-postgres-rustls feature, which in turn adds tokio-postgres-rustls dependency.
This makes it possible to use rustls instead of openssl for TLS termination. It only works for async connections.

Please note: I have added ISC to the list of allowed licenses, as this check was failing.

tomasol and others added 3 commits April 22, 2026 19:24
When tokio-postgres or postgres features are enabled without the tls
feature, config.rs still referenced native_tls and postgres_native_tls
crates that are no longer pulled in. Guard those code paths with
#[cfg(feature = "tls")] so that no-TLS builds do not require openssl.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Instead of silently falling back to an unencrypted connection when
use_tls() is true but the 'tls' feature is disabled, panic with a
clear message so the misconfiguration is immediately visible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new `tokio-postgres-rustls` feature to refinery/refinery-core
that provides TLS for the config-based tokio-postgres connection path
using rustls instead of native-tls/openssl.

Design: no crypto provider is bundled. Callers must install a global
provider (e.g. ring or aws-lc-rs) before running migrations with TLS.
System trust roots are loaded via rustls-native-certs. When use_tls()
is true but the feature is disabled, a clear panic is raised.

Note: tokio-postgres-rustls 0.13 has an unconditional ring dep for
certificate fingerprinting (unrelated to the TLS crypto provider).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tomasol tomasol force-pushed the pr-rustls-postgres branch from ce4d5a2 to 2a06555 Compare April 22, 2026 17:27
Copy link
Copy Markdown
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, and thanks for this, overall looks good to me! Can you add a test case for this? I think we have one for the native tls one

@tomasol tomasol force-pushed the pr-rustls-postgres branch from e1d4b7b to 2d55cf1 Compare April 23, 2026 19:20
Also make postgres connection string configurable via `POSTGRES_URL` environment
variable.
@tomasol tomasol force-pushed the pr-rustls-postgres branch from 2d55cf1 to 70e90e0 Compare April 23, 2026 19:36
@tomasol tomasol requested a review from jxs April 25, 2026 20:13
@tomasol
Copy link
Copy Markdown
Contributor Author

tomasol commented Apr 25, 2026

Hi, and thanks for this, overall looks good to me! Can you add a test case for this? I think we have one for the native tls one

sure, I've added a test.

Copy link
Copy Markdown
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jxs jxs merged commit 6074795 into rust-db:main Apr 27, 2026
56 of 58 checks passed
@tomasol
Copy link
Copy Markdown
Contributor Author

tomasol commented Apr 27, 2026

Thanks for working on this awesome library!

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