Skip to content

Commit

Permalink
remove http scheme check
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Jul 20, 2023
1 parent c777809 commit 31c5d2d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
4 changes: 0 additions & 4 deletions crates/core/src/conn/native_tls/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ where
http_version,
http_scheme,
} = self.inner.accept().await?;
if http_scheme == Scheme::HTTPS {
let conn = tls_acceptor
.accept(conn)
.await
Expand All @@ -175,8 +174,5 @@ where
http_version,
http_scheme,
})
} else {
Err(IoError::new(ErrorKind::Other, "native_tls: invalid scheme."))
}
}
}
34 changes: 15 additions & 19 deletions crates/core/src/conn/openssl/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,20 @@ where
http_version,
http_scheme,
} = self.inner.accept().await?;
if http_scheme == Scheme::HTTPS {
let ssl = Ssl::new(tls_acceptor.context()).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?;
let mut tls_stream =
SslStream::new(ssl, conn).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?;
use std::pin::Pin;
Pin::new(&mut tls_stream)
.accept()
.await
.map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?;
Ok(Accepted {
conn: tls_stream,
local_addr,
remote_addr,
http_version,
http_scheme,
})
} else {
Err(IoError::new(ErrorKind::Other, "openssl: invalid scheme."))
}
let ssl = Ssl::new(tls_acceptor.context()).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?;
let mut tls_stream =
SslStream::new(ssl, conn).map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?;
use std::pin::Pin;
Pin::new(&mut tls_stream)
.accept()
.await
.map_err(|err| IoError::new(ErrorKind::Other, err.to_string()))?;
Ok(Accepted {
conn: tls_stream,
local_addr,
remote_addr,
http_version,
http_scheme,
})
}
}
26 changes: 11 additions & 15 deletions crates/core/src/conn/rustls/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,16 @@ where
http_version,
http_scheme,
} = self.inner.accept().await?;
if http_scheme == Scheme::HTTPS {
let conn = tls_acceptor
.accept(conn)
.await
.map_err(|e| IoError::new(ErrorKind::Other, e.to_string()))?;
Ok(Accepted {
conn,
local_addr,
remote_addr,
http_version,
http_scheme,
})
} else {
Err(IoError::new(ErrorKind::Other, "rustls: invalid scheme."))
}
let conn = tls_acceptor
.accept(conn)
.await
.map_err(|e| IoError::new(ErrorKind::Other, e.to_string()))?;
Ok(Accepted {
conn,
local_addr,
remote_addr,
http_version,
http_scheme,
})
}
}

0 comments on commit 31c5d2d

Please sign in to comment.