async-rs / async-tls

A TLS implementation over AsyncRead and AsyncWrite
https://async.rs
Apache License 2.0
167 stars 47 forks source link

Export rustls crates #49

Open FssAy opened 1 year ago

FssAy commented 1 year ago

The rustls and rustls-pemfile in my opinion should be exported by async-tls as the library exposes functionality that requires a deep understanding of the types and functionality of the rustls crate. The current state requires user to import the rustls crate on their own while it might cause errors while importing the wrong version. For example:

async_tls::TlsAcceptor::from(std::sync::Arc(
     rustls::ServerConfig::builder().with_safe_defaults()?
));
the trait `From<std::sync::Arc<rustls::ServerConfig>>` is not implemented for `TlsAcceptor`
the following other types implement trait `From<T>`:
      <TlsAcceptor as From<std::sync::Arc<rustls::server::server_conn::ServerConfig>>>

This simple change would eliminate the issue:

async_tls::TlsAcceptor::from(std::sync::Arc(
     async_tls::rustls::ServerConfig::builder().with_safe_defaults()?
));