Repository navigation
Conversation
abonander
force-pushed
the
ab/rustls-overhaul
branch
from
November 25, 2026 07:15
759b0ae to
58ac676
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is intended to be backwards-compatible, so the plan doesn't match #4408 exactly. However, I think this is a significant step in the right direction.
Please help test it and report any regressions.
Cargo Feature Changes
The intention is to decompose the TLS features in the same way that was previously done to the
runtime-*features.This PR adds a few temporary features to provide a migration path for changes to their existing counterparts:
tls-rustls-basewhich enablesrustlsbut no crypto provider or TLS roots. In the future this will be folded intotls-rustls.tls-rustls-aws-lc-rs-no-rootswhich enables theaws-lc-rscrypto provider without setting any TLS roots. In the future, this will be folded intotls-rustls-aws-lc-rs.tls-rustls-ring-no-rootswhich does the same thing forring.These features are additive with the new TLS root features:
tls-rustls-native-rootsenables just native roots without explicitly enabling a crypto provider.tls-rustls-webpki-rootsdoes the same forwebpki-roots.I considered adding
rustls-platform-verifierbut as discussed in #4408, I'm rather uncomfortable with how platform-dependent its guarantees are, and I am still worried about it exacerbating #3211. However, it's at least now possible to userustls-platform-verifierby building a customrustls::ClientConfig.The existing combination features (e.g.
tls-rustls-aws-lc-rs-native-roots) are hereby deprecated by this PR, though we unfortunately don't have a good way to signal this to the user.Also documented are some future breaking changes (targeted for 0.10):
tls-rustlswill subsumetls-rustls-base; it will no longer implytls-rustls-ring.tls-rustls-ringandtls-rustls-aws-lc-rswill subsume their-no-rootscounterparts and no longer implywebpki-roots.New APIs
MySqlConnectOptionsandPgConnectOptionsgain the following setters:ssl_include_root_bundle, a boolean flag that enables or disables the root bundle provided bynative-rootsorwebpki-roots.sslrootcertis added to the root certificate store rather than replacing it. In addition to the-no-rootsfeatures, this flag makes it possible to guarantee that only the provided bundle is used.rustls_crypto_provider, which allows setting a customCryptoProvider. Included is an example forrustls-graviolasince I'm not quite comfortable providing it as a default option yet due to its immaturity.CryptoProvider(CryptoProvider::get_default()) because that API will be deleted in RusTLS 0.24. It thus does not make sense to write code that depends on this API. Instead, you can use the new setter to pass the globalCryptoProvideryourself.rustls_client_configallows passing a fullrustls::ClientConfigwhich can bypass most of SQLx's default behavior regarding TLS. BesidesMySqlSslMode/PgSslMode, which control whether the TLS handshake is made at all, all other TLS configuration options become no-ops.tls-native-tlsfeature if that is also enabled, which allows overriding native TLS if a transitive dependency enables it unconditionally.ConnectOptions::to_url_lossy()addsdanger-custom-rustls-config=trueto the URL. Parsing a URL with this parameter will requirerustls_client_configbefore attempting to connect, or else an error will be returned.