Skip to content

Commit

Permalink
chore(tls): Refactor tls alpn protocol check (#1681)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored May 21, 2024
1 parent fcf7a65 commit 7551d5d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tonic/src/transport/service/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ impl TlsConnector {
// explicitly set `assume_http2` to true, we'll allow it to be missing.
let (_, session) = io.get_ref();
let alpn_protocol = session.alpn_protocol();
if alpn_protocol != Some(ALPN_H2) {
if alpn_protocol.is_some() || !self.assume_http2 {
return Err(TlsError::H2NotNegotiated.into());
}
if !(alpn_protocol == Some(ALPN_H2) || self.assume_http2) {
return Err(TlsError::H2NotNegotiated.into());
}
Ok(BoxedIo::new(io))
}
Expand Down

0 comments on commit 7551d5d

Please sign in to comment.