How to implement ClientCertVerifier trait of rustTls

I tried to implement the trait ClientCertVerifier, I need the method that check the client certificate the problem is when I write this block of code

impl ClientCertVerifier for rustls::NoClientAuth {
    fn verify_client_cert(

        &self,

        presented_certs: &[Certificate],

        sni: Option<&DNSName>,

    ) -> Result<ClientCertVerified, TLSError> {
        // My code to check the ceritificate
        todo!()

    }
}

I get this error :

conflicting implementations of trait rustls::ClientCertVerifier for type rustls::NoClientAuth:
conflicting implementation in crate rustls:

  • impl ClientCertVerifier for NoClientAuth;

What I'm doing wrong ?

What's the problem you're trying to solve by writing this impl? You can't implement a trait for a type when both of them are defined outside the current crate, and anyway rustls::NoClientAuth already implements rustls::ClientCertVerifier, so this shouldn't be necessary.

If you want to define your own checking behavior you could define your own type MyClientAuth and then impl ClientCertVerifier for MyClientAuth. I can't say for certain whether that's the right thing to do here because I'm not familiar with rustls or what you're trying to do in your custom checking logic.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.