quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.57k stars 364 forks source link

Using `rustls` v22 and greater with quinn #1795

Closed ReeceHumphreys closed 3 months ago

ReeceHumphreys commented 3 months ago

The documentation shows an example of how to integrate rustls with quinn:

    let crypto = rustls::ClientConfig::builder()
        .with_safe_defaults()
        .with_custom_certificate_verifier(SkipServerVerification::new())
        .with_no_client_auth();

    ClientConfig::new(Arc::new(crypto))

However, the API for rustls has slightly changed and this example no longer seems to work:

        let crypto = rustls::ClientConfig::builder()
            .with_root_certificates(roots)
            .with_no_client_auth();

        quinn::ClientConfig::new(Arc::new(crypto));

Error:

error[E0277]: the trait bound `rustls::ClientConfig: quinn::crypto::ClientConfig` is not satisfied
  --> src/icerpc_connection.rs:38:54
   |
38 |         let client_config = quinn::ClientConfig::new(Arc::new(crypto));
   |                                                      ^^^^^^^^^^^^^^^^ the trait `quinn::crypto::ClientConfig` is not implemented for `rustls::ClientConfig`
   |
   = help: the trait `quinn::crypto::ClientConfig` is implemented for `rustls::client::client_conn::ClientConfig`
   = note: required for the cast from `Arc<rustls::ClientConfig>` to `Arc<(dyn quinn::crypto::ClientConfig + 'static)>`

Any help with resolving this would be greatly appreciated!

ReeceHumphreys commented 3 months ago

I suspect https://github.com/quinn-rs/quinn/pull/1715 would resolve my issue but I am looking for a workaround in the meantime if possible!

djc commented 3 months ago

Look at the examples from any Git tags?

djc commented 3 months ago

In general Quinn does not and will not support rustls 0.22. It will support rustls 0.23 after #1715 lands. If you want to get something working today, you can either use released Quinn with rustls 0.21 or try to make a git dependency work with rustls 0.23 (but I will be force-pushing to the #1715 branch, so it's not a very stable target right now).

ReeceHumphreys commented 3 months ago

Thanks for the guidance!

jonatanzeidler commented 2 months ago

To me looks a lot like #1600 and #300. You can check whether you have multiple versions of rustls in your dependency tree and if so, try to change them to be the same.