Repository navigation
Conversation
Add `Config::rustls_client_config(Arc<rustls::ClientConfig>)` and its `ConfigBuilder` mirror (rustls only). When set, the TLS handshake uses the caller's configuration as-is (verifier, roots, client authentication and crypto provider) instead of one built from the trust settings, which are then not consulted. For `EncryptionLevel::Strict` the `tds/8.0` ALPN protocol is added to a copy if missing; the caller's configuration is never modified. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
Adds
Config::rustls_client_config(Arc<rustls::ClientConfig>)(and theConfigBuildermirror), behind the existingrustlsfeature. When set, the TLS handshake uses the caller's configuration instead of one built from the trust settings.Use case: applications that already manage rustls themselves (a custom
ServerCertVerifier, a root store shared with their other database clients, a specificCryptoProvider, client authentication through aResolvesClientCert, session resumption or key logging) and want SQL Server verified the same way as everything else, without mapping their policy ontotrust_cert_ca/trust_webpki_roots.Behaviour
trust_cert,trust_cert_ca,trust_cert_ca_bundle,trust_webpki_roots, and their connection-string equivalents) andclient_certificateare not consulted. Atrust_cert()from a connection string therefore cannot weaken a caller's verifier (there is a test for this).hostname_in_certificate(orhost).EncryptionLevel::Strict,tds/8.0is added to the ALPN list of a copy if it is not already there. The caller'sArc<ClientConfig>is never modified. Without strict encryption the sameArcis used.trust_cert_ca/trust_certhints frommap_handshake_error, since those settings don't apply.client_config(&Config)helper so it can be unit-tested; its logic is the same.Relation to #456 / #457
This complements #456 (
rustls-no-provider) and doesn't overlap with it. With a caller-supplied configuration the provider comes from theClientConfig, so an application onrustls-no-providerdoesn't need a process-wide default provider for tiberius. If #456 merges first, the only change here is the gate:feature = "rustls"becomesfeature = "rustls-no-provider"in the three newcfgs (the test helpers use aws-lc-rs and would need the same gating as #456's tests). I'm happy to rebase onto whichever lands first.Tests
rustls_tls_stream): the caller's config is used unchanged (Arc::ptr_eq); strict addstds/8.0exactly once, keeps the caller's provider and doesn't mutate the caller's config; trust settings aren't read (an unreadable CA file fails the built-in path but not this one).docker/certs/server.crtovertokio::io::duplex, with the verification time pinned inside the fixture's validity window: a strict handshake completes and the server negotiatestds/8.0; withtrust_cert()also set, a caller config that doesn't trustcustomCAstill rejects the server (UnknownIssuer).config): default, setter and builder.tests/custom-cert.rs):connect_to_custom_cert_instance_rustls_client_configconnects to the custom-cert instance with aClientConfigthat trusts onlycustomCA.Run locally:
Changelog
Added under a new
## Unreleasedheading.🤖 Generated with Claude Code