Skip to content

feat(transport): allow setting a custom rustls CryptoProvider on TLS configs#2697

Open
jgowdy wants to merge 1 commit into
grpc:masterfrom
jgowdy:feat/tls-with-provider
Open

feat(transport): allow setting a custom rustls CryptoProvider on TLS configs#2697
jgowdy wants to merge 1 commit into
grpc:masterfrom
jgowdy:feat/tls-with-provider

Conversation

@jgowdy

@jgowdy jgowdy commented Jun 21, 2026

Copy link
Copy Markdown

Motivation

ClientTlsConfig and ServerTlsConfig build their rustls configuration from
CryptoProvider::get_default(), so a non-default provider can only be used by
installing it process-wide with install_default. That forces every rustls user
in the process onto the same provider. Some applications want a non-default
provider, for example a FIPS build or a provider that constrains the cipher
suites and key-exchange groups (such as a post-quantum profile), on specific
channels or servers only.

Closes #2696.

Solution

Add a with_provider(Arc<CryptoProvider>) builder method to both
ClientTlsConfig and ServerTlsConfig. When set, tonic builds the rustls config
with builder_with_provider instead of get_default(); roots, identity, ALPN,
and client auth are layered on top unchanged. The field is optional and defaults
to the existing behavior, so this is backward compatible.

This follows the pattern of the custom ServerCertVerifier escape hatch (#2612).

A unit test covers that a client connector built with an explicit provider
succeeds without a process-wide default installed. The server path is symmetric.
There is no integration-test harness for tonic::transport TLS in the repo, and
the example certs live outside the tonic crate, so I kept the test
self-contained. Happy to add an integration test if you would prefer one.

…configs

ClientTlsConfig and ServerTlsConfig build their rustls config from
CryptoProvider::get_default(), so a non-default provider could only be used by
installing it process-wide with install_default. Add a with_provider builder
method to both configs to set the provider per channel/server; when set, tonic
builds the config with builder_with_provider instead of get_default(). Roots,
identity, ALPN, and client auth are layered on top unchanged. The field is
optional and defaults to the current behavior, so it is backward compatible.
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 21, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: jgowdy / name: Jay Gowdy (008bd92)

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.

Allow configuring a custom rustls CryptoProvider on ClientTlsConfig and ServerTlsConfig

1 participant