Skip to content

Commit

Permalink
Fix error in the initial TLS server impl (#250)
Browse files Browse the repository at this point in the history
* Update README.md

* added variants for tls conn

* server performs tls handshake if tls_config exists

* need alt for make tls transport

* modified ServerTlsConfig, added ClientTlsConfig

* adding tls_config method

* changed client tls connector to an enum

* stop tracking Cargo.lock

* wrap native tls acceptor/connector with Arc

* cargo fmt

* added #[cfg] to deal w/ unused imports

* replace cfg attr w/ macro

* pub re-export TlsAcceptor and ServerTlsConfig

* added more cfg for rustls and native-tls

* changed cfg attr to macro

* made client tls config fields public

* added constructors

* added tls connector

* added example for tls

* moved dep features behind tls feature

* removed attr impl_trait_in_assoc_type

* moved deps to workspace

* feature gate mod tls and re-export

* move dep to workspace

* minor fix

* gate import behind feature gate

* renamed domain to server_name

* cargo fmt and hide import behind feature

* remove Cargo.lock from gitignore

* only enable doc_cfg when building on docs.rs

* do not return err from loop upon TLS handshake err
  • Loading branch information
minghuaw authored Oct 27, 2023
1 parent 4981534 commit 25885a7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions volo-grpc/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,27 @@ impl<L> Server<L> {
match (conn.stream, self.tls_config.as_ref().map(|o| &o.acceptor)) {
#[cfg(feature = "rustls")]
(volo::net::conn::ConnStream::Tcp(tcp), Some(TlsAcceptor::Rustls(tls_acceptor))) => {
let stream = tls_acceptor.accept(tcp).await?;
let stream = match tls_acceptor.accept(tcp).await {
Ok(stream) => stream,
Err(err) => {
tracing::debug!("[VOLO] TLS handshake error: {:?}", err);
continue;
},
};
Conn {
stream: ConnStream::Rustls(tokio_rustls::TlsStream::Server(stream)),
info
}
},
#[cfg(feature = "native-tls")]
(volo::net::conn::ConnStream::Tcp(tcp), Some(TlsAcceptor::NativeTls(tls_acceptor))) => {
let stream = tls_acceptor.accept(tcp).await?;
let stream = match tls_acceptor.accept(tcp).await {
Ok(stream) => stream,
Err(err) => {
tracing::debug!("[VOLO] TLS handshake error: {:?}", err);
continue;
},
};
Conn {
stream: ConnStream::NativeTls(stream),
info,
Expand Down

0 comments on commit 25885a7

Please sign in to comment.