Skip to content

Commit 16d126e

Browse files
author
Peter Thorson
committed
Remove custom handling of SSL_R_SHORT_READ errors. fixes #599
1 parent 9ddb300 commit 16d126e

File tree

5 files changed

+22
-36
lines changed

5 files changed

+22
-36
lines changed

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ HEAD
2424
specified instead (This was the previous behavior). #596 #653 Thank you
2525
Vinnie Falco and Gianfranco Costamagna for reporting.
2626
- Compatibility: Better error handling and logging in cases where extension
27-
requests parse correctly but negotiation fails.
27+
requests parse correctly but negotiation fails.
28+
- Compatibility: Removed custom handling of SSL_R_SHORT_READ error condition.
29+
This error code no longer exists in modern versions of OpenSSL and causes
30+
a build error. It wasn't being used for anything particularly important
31+
(slightly improving error reporting) and there isn't a great replacement.
32+
#599 Thank you Gianfranco Costamagna for reporting.
2833
- Bug: Store loggers in shared pointers to avoid crashes related to connections
2934
trying to write logs entries after their respective endpoint has been
3035
deallocated. Thank you Thalhammer for reporting and Jupp Müller for the

websocketpp/common/asio.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ namespace lib {
8888
inline lib::chrono::milliseconds milliseconds(long duration) {
8989
return lib::chrono::milliseconds(duration);
9090
}
91+
92+
} // namespace error
93+
} // namespace ssl
9194
} // namespace asio
9295

9396
#else

websocketpp/impl/connection_impl.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -999,19 +999,16 @@ void connection<config>::handle_read_frame(lib::error_code const & ec,
999999
"handle_read_frame: got invalid istate in closed state");
10001000
return;
10011001
}
1002-
} else if (ecm == transport::error::tls_short_read) {
1003-
if (m_state == session::state::closed) {
1004-
// We expect to get a TLS short read if we try to read after the
1005-
// connection is closed. If this happens ignore and exit the
1006-
// read frame path.
1007-
terminate(lib::error_code());
1008-
return;
1009-
}
1010-
echannel = log::elevel::rerror;
10111002
} else if (ecm == transport::error::action_after_shutdown) {
10121003
echannel = log::elevel::info;
1004+
} else {
1005+
// TODO: more generally should we do something different here in the
1006+
// case that m_state is cosed? Are errors after the connection is
1007+
// already closed really an rerror?
10131008
}
10141009

1010+
1011+
10151012
log_err(echannel, "handle_read_frame", ecm);
10161013
this->terminate(ecm);
10171014
return;

websocketpp/transport/asio/connection.hpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,17 +1116,10 @@ class connection : public config::socket_type::socket_con_type {
11161116
tec = socket_con_type::translate_ec(ec);
11171117
m_tec = ec;
11181118

1119-
if (tec == transport::error::tls_short_read) {
1120-
// TLS short read at this point is somewhat expected if both
1121-
// sides try and end the connection at the same time or if
1122-
// SSLv2 is being used. In general there is nothing that can
1123-
// be done here other than a low level development log.
1124-
} else {
1125-
// all other errors are effectively pass through errors of
1126-
// some sort so print some detail on the info channel for
1127-
// library users to look up if needed.
1128-
log_err(log::elevel::info,"asio async_shutdown",ec);
1129-
}
1119+
// all other errors are effectively pass through errors of
1120+
// some sort so print some detail on the info channel for
1121+
// library users to look up if needed.
1122+
log_err(log::elevel::info,"asio async_shutdown",ec);
11301123
}
11311124
} else {
11321125
if (m_alog->static_test(log::alevel::devel)) {

websocketpp/transport/asio/security/tls.hpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,9 @@ class connection : public lib::enable_shared_from_this<connection> {
355355
template <typename ErrorCodeType>
356356
lib::error_code translate_ec(ErrorCodeType ec) {
357357
if (ec.category() == lib::asio::error::get_ssl_category()) {
358-
if (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ) {
359-
return make_error_code(transport::error::tls_short_read);
360-
} else {
361-
// We know it is a TLS related error, but otherwise don't know
362-
// more. Pass through as TLS generic.
363-
return make_error_code(transport::error::tls_error);
364-
}
358+
// We know it is a TLS related error, but otherwise don't know more.
359+
// Pass through as TLS generic.
360+
return make_error_code(transport::error::tls_error);
365361
} else {
366362
// We don't know any more information about this error so pass
367363
// through
@@ -372,14 +368,6 @@ class connection : public lib::enable_shared_from_this<connection> {
372368
/// Overload of translate_ec to catch cases where lib::error_code is the
373369
/// same type as lib::asio::error_code
374370
lib::error_code translate_ec(lib::error_code ec) {
375-
// Normalize the tls_short_read error as it is used by the library and
376-
// needs a consistent value. All other errors pass through natively.
377-
// TODO: how to get the SSL category from std::error?
378-
/*if (ec.category() == lib::asio::error::get_ssl_category()) {
379-
if (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ) {
380-
return make_error_code(transport::error::tls_short_read);
381-
}
382-
}*/
383371
return ec;
384372
}
385373
private:

0 commit comments

Comments
 (0)