Skip to content

Allow direct access to modify the TLS config #2238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

n1ght-hunter
Copy link

Motivation

For work we need direct access to the tls config to customise the ServerCertVerifier.
Also direct access allow any further config changes to made without any changes to tonic

Solution

To solve access to the tls i have added a method to ClientTlsConfig called modify_config(could be named somthing else maybe).

 pub fn modify_config<F>(self, f: F) -> Self
    where
        F: Fn(&mut tokio_rustls::rustls::ClientConfig) + Send + Sync + 'static,
    {
        let modify_config = ModdifyConfigFn(std::sync::Arc::new(f));
        ClientTlsConfig {
            modify_config: Some(modify_config),
            ..self
        }
    }

this allows users to directly modify tokio_rustls::rustls::ClientConfig to fit their needs.
this function is called in TlsConnector::new after all tonic config changes are set

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.

1 participant