Skip to content

Commit

Permalink
Fix Diplay panics for HandshakeError with rpk (fixes #140)
Browse files Browse the repository at this point in the history
  • Loading branch information
inikulin committed Aug 3, 2023
1 parent 308f040 commit bb063aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions boring/src/ssl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ fn fmt_mid_handshake_error(
f: &mut fmt::Formatter,
prefix: &str,
) -> fmt::Result {
#[cfg(feature = "rpk")]
if s.ssl().ssl_context().is_rpk() {
write!(f, "{}", prefix)?;
return write!(f, " {}", s.error());
}

match s.ssl().verify_result() {
X509VerifyResult::OK => write!(f, "{}", prefix)?,
verify => write!(f, "{}: cert verification failed - {}", prefix, verify)?,
Expand Down
7 changes: 5 additions & 2 deletions tokio-boring/tests/rpk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ mod test_rpk {

let stream = TcpStream::connect(&addr).await.unwrap();

assert!(tokio_boring::connect(config, "localhost", stream)
let err = tokio_boring::connect(config, "localhost", stream)
.await
.is_err());
.unwrap_err();

// NOTE: smoke test for https://github.com/cloudflare/boring/issues/140
let _ = err.to_string();
};

future::join(server, client).await;
Expand Down

0 comments on commit bb063aa

Please sign in to comment.