Skip to content

Commit fddd1ce

Browse files
noxkornelski
authored andcommitted
Don't return shutdown errors during shutdown
1 parent 47c33f6 commit fddd1ce

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
@@ -4069,7 +4069,24 @@ impl<S: Read + Write> SslStream<S> {
40694069
match unsafe { ffi::SSL_shutdown(self.ssl.as_ptr()) } {
40704070
0 => Ok(ShutdownResult::Sent),
40714071
1 => Ok(ShutdownResult::Received),
4072-
n => Err(self.make_error(n)),
4072+
n => {
4073+
let e = self.make_error(n);
4074+
4075+
// If boring returns PROTOCOL_IS_SHUTDOWN then the connection
4076+
// has already been shutdown and we can just return Ok(()), as
4077+
// this was exactly what we wanted to do anyway.
4078+
if e.code() == ErrorCode::SSL {
4079+
if let Some(stack) = e.ssl_error() {
4080+
if let Some(first) = stack.errors().first() {
4081+
if first.code() as i32 == boring_sys::SSL_R_PROTOCOL_IS_SHUTDOWN {
4082+
return Ok(ShutdownResult::Received);
4083+
}
4084+
}
4085+
}
4086+
}
4087+
4088+
Err(e)
4089+
}
40734090
}
40744091
}
40754092

0 commit comments

Comments
 (0)