Backward compatibility for code using OpenSSL < 1.1.0.
Some application code using asio::ssl::stream<> explicitly tests for the
SSL_R_SHORT_READ error. For compatibility, when using older versions of
OpenSSL we will define the ssl::error::stream_truncated to use this
value.
diff --git a/asio/include/asio/ssl/error.hpp b/asio/include/asio/ssl/error.hpp
index 99c9dd3..3efef0c 100644
--- a/asio/include/asio/ssl/error.hpp
+++ b/asio/include/asio/ssl/error.hpp
@@ -40,8 +40,14 @@
enum stream_errors
{
+#if defined(GENERATING_DOCUMENTATION)
/// The underlying stream closed before the ssl stream gracefully shut down.
+ stream_truncated
+#elif (OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL)
+ stream_truncated = ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ)
+#else
stream_truncated = 1
+#endif
};
extern ASIO_DECL
diff --git a/asio/include/asio/ssl/impl/error.ipp b/asio/include/asio/ssl/impl/error.ipp
index 3ff2575..268fc96 100644
--- a/asio/include/asio/ssl/impl/error.ipp
+++ b/asio/include/asio/ssl/impl/error.ipp
@@ -51,6 +51,16 @@
} // namespace error
namespace ssl {
namespace error {
+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL)
+
+const asio::error_category& get_stream_category()
+{
+ return asio::error::get_ssl_category();
+}
+
+#else
+
namespace detail {
class stream_category : public asio::error_category
@@ -79,6 +89,8 @@
return instance;
}
+#endif
+
} // namespace error
} // namespace ssl
} // namespace asio