aws / s2n-quic

An implementation of the IETF QUIC protocol
https://crates.io/crates/s2n-quic
Apache License 2.0
1.17k stars 119 forks source link

[ConfigLoader] Provider not implemented for generic Server<T> #1573

Open benlcb opened 2 years ago

benlcb commented 2 years ago

Problem:

A recent commit introduced a ConfigLoader. ConfigLoader is used in lieu of a static certificate when creating a TLS server, so the QUIC server can reload TLS certificates when needed.

Using the ConfigLoader looks something like this:

struct QuicTlsLoader {
    tls: Arc<TlsMaterials>,
}

impl s2n_quic::provider::tls::s2n_tls::ConfigLoader for QuicTlsLoader {
    fn load(
        &mut self,
        cx: s2n_quic::provider::tls::s2n_tls::ConnectionContext,
    ) -> s2n_tls::config::Config {
        // build a s2n_tls config with current certificate
        return myConfig
    }
}

let loader = QuicTlsLoader{ tls };
let tls_provider =
     s2n_quic::provider::tls::default::Server::from_loader(loader);

let server = s2n_quic::Server::builder()
.with_tls(tls_provider)?
.start();

At which point the compiler complains:

the trait bound s2n_quic::provider::tls::default::Server<QuicTlsLoader>: s2n_quic::provider::tls::Provider is not satisfied the trait s2n_quic::provider::tls::Provider is implemented for s2n_quic::provider::tls::default::Server required for s2n_quic::server::Builder<impl ServerProviders> to implement s2n_quic::provider::tls::With<s2n_quic::provider::tls::default::Server<QuicTlsLoader>>rustcE0277 required by a bound in s2n_quic::server::Builder::<Providers>::with_tls

Solution:

Modify the s2n_quic::provider::tls::Provider to implement Provider for generic Server<T>.

Requirements / Acceptance Criteria:

The developer can now use ConfigLoader without having to implement Provider for the resulting Server<T> themselves.

WesleyRosenblum commented 1 year ago

Thanks for opening this issue, we'll take a look