Skip to content

Commit 38ff0e5

Browse files
noxkornelski
authored andcommitted
Don't return shutdown errors during shutdown
1 parent b01510d commit 38ff0e5

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

boring/src/ssl/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4190,7 +4190,24 @@ impl<S: Read + Write> SslStream<S> {
41904190
match unsafe { ffi::SSL_shutdown(self.ssl.as_ptr()) } {
41914191
0 => Ok(ShutdownResult::Sent),
41924192
1 => Ok(ShutdownResult::Received),
4193-
n => Err(self.make_error(n)),
4193+
n => {
4194+
let e = self.make_error(n);
4195+
4196+
// If boring returns PROTOCOL_IS_SHUTDOWN then the connection
4197+
// has already been shutdown and we can just return Ok(()), as
4198+
// this was exactly what we wanted to do anyway.
4199+
if e.code() == ErrorCode::SSL {
4200+
if let Some(stack) = e.ssl_error() {
4201+
if let Some(first) = stack.errors().first() {
4202+
if first.code() as i32 == boring_sys::SSL_R_PROTOCOL_IS_SHUTDOWN {
4203+
return Ok(ShutdownResult::Received);
4204+
}
4205+
}
4206+
}
4207+
}
4208+
4209+
Err(e)
4210+
}
41944211
}
41954212
}
41964213

0 commit comments

Comments
 (0)