Change ssl stream implementations
Boost beast ssl_stream is just a wrapper around asio ssl_stream, and
aims to optimize the case where we're writing small payloads (one or two
bytes.) which needs to be optimized in SSL.
bmcweb never writes one or two bytes, we almost always write the full
payload of what we received, so there's no reason to take the binary
size overhead, and additional boost headers that this implementation
requires.
Tested:
This drops the on-target binary size by 2.6%
Redfish service validator passes.
Change-Id: Ie1ae6f197f8e5ed70cf4abc6be9b1b382c42d64d
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/http/app.hpp b/http/app.hpp
index d7863f6..01ad755 100644
--- a/http/app.hpp
+++ b/http/app.hpp
@@ -13,7 +13,7 @@
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/context.hpp>
-#include <boost/beast/ssl/ssl_stream.hpp>
+#include <boost/asio/ssl/stream.hpp>
#include <chrono>
#include <cstdint>
@@ -32,7 +32,7 @@
class App
{
public:
- using ssl_socket_t = boost::beast::ssl_stream<boost::asio::ip::tcp::socket>;
+ using ssl_socket_t = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>;
using raw_socket_t = boost::asio::ip::tcp::socket;
using socket_type =
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index 3e0c394..7e8224e 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -22,7 +22,6 @@
#include <boost/beast/http/read.hpp>
#include <boost/beast/http/serializer.hpp>
#include <boost/beast/http/write.hpp>
-#include <boost/beast/ssl/ssl_stream.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/system/error_code.hpp>
@@ -545,7 +544,7 @@
void close()
{
if constexpr (std::is_same_v<Adaptor,
- boost::beast::ssl_stream<
+ boost::asio::ssl::stream<
boost::asio::ip::tcp::socket>>)
{
adaptor.next_layer().close();
diff --git a/http/http_client.hpp b/http/http_client.hpp
index f44107b..860a7d4 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -28,6 +28,7 @@
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/context.hpp>
#include <boost/asio/ssl/error.hpp>
+#include <boost/asio/ssl/stream.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/http/message.hpp>
@@ -35,7 +36,6 @@
#include <boost/beast/http/parser.hpp>
#include <boost/beast/http/read.hpp>
#include <boost/beast/http/write.hpp>
-#include <boost/beast/ssl/ssl_stream.hpp>
#include <boost/container/devector.hpp>
#include <boost/system/error_code.hpp>
#include <boost/url/format.hpp>
@@ -157,7 +157,7 @@
Resolver resolver;
boost::asio::ip::tcp::socket conn;
- std::optional<boost::beast::ssl_stream<boost::asio::ip::tcp::socket&>>
+ std::optional<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>
sslConn;
boost::asio::steady_timer timer;
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 6ec8831..bd8cf31 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -26,7 +26,6 @@
#include <boost/beast/http/parser.hpp>
#include <boost/beast/http/read.hpp>
#include <boost/beast/http/write.hpp>
-#include <boost/beast/ssl/ssl_stream.hpp>
#include <boost/beast/websocket.hpp>
#include <atomic>
@@ -52,7 +51,7 @@
{};
template <typename T>
-struct IsTls<boost::beast::ssl_stream<T>> : std::true_type
+struct IsTls<boost::asio::ssl::stream<T>> : std::true_type
{};
template <typename Adaptor, typename Handler>
diff --git a/http/http_server.hpp b/http/http_server.hpp
index da73b10..a370894 100644
--- a/http/http_server.hpp
+++ b/http/http_server.hpp
@@ -8,8 +8,8 @@
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/asio/ssl/context.hpp>
+#include <boost/asio/ssl/stream.hpp>
#include <boost/asio/steady_timer.hpp>
-#include <boost/beast/ssl/ssl_stream.hpp>
#include <atomic>
#include <chrono>
@@ -150,7 +150,7 @@
boost::asio::steady_timer timer(*ioService);
std::shared_ptr<Connection<Adaptor, Handler>> connection;
if constexpr (std::is_same<Adaptor,
- boost::beast::ssl_stream<
+ boost::asio::ssl::stream<
boost::asio::ip::tcp::socket>>::value)
{
if (adaptorCtx == nullptr)
diff --git a/http/routing/baserule.hpp b/http/routing/baserule.hpp
index f99e16e..f6ba8d2 100644
--- a/http/routing/baserule.hpp
+++ b/http/routing/baserule.hpp
@@ -5,7 +5,8 @@
#include "privileges.hpp"
#include "verb.hpp"
-#include <boost/beast/ssl/ssl_stream.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/asio/ssl/stream.hpp>
#include <memory>
#include <string>
@@ -48,7 +49,7 @@
virtual void handleUpgrade(
const Request& /*req*/,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- boost::beast::ssl_stream<boost::asio::ip::tcp::socket>&& /*adaptor*/)
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket>&& /*adaptor*/)
{
asyncResp->res.result(boost::beast::http::status::not_found);
}
diff --git a/http/routing/sserule.hpp b/http/routing/sserule.hpp
index ad05baf..5b55658 100644
--- a/http/routing/sserule.hpp
+++ b/http/routing/sserule.hpp
@@ -43,13 +43,13 @@
}
void handleUpgrade(const Request& /*req*/,
const std::shared_ptr<bmcweb::AsyncResp>& /*asyncResp*/,
- boost::beast::ssl_stream<boost::asio::ip::tcp::socket>&&
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket>&&
adaptor) override
{
std::shared_ptr<crow::sse_socket::ConnectionImpl<
- boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>>
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>>
myConnection = std::make_shared<crow::sse_socket::ConnectionImpl<
- boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>>(
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>>(
std::move(adaptor), openHandler, closeHandler);
myConnection->start();
}
diff --git a/http/routing/websocketrule.hpp b/http/routing/websocketrule.hpp
index b52d9ec..0905b08 100644
--- a/http/routing/websocketrule.hpp
+++ b/http/routing/websocketrule.hpp
@@ -43,14 +43,14 @@
void handleUpgrade(const Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& /*asyncResp*/,
- boost::beast::ssl_stream<boost::asio::ip::tcp::socket>&&
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket>&&
adaptor) override
{
BMCWEB_LOG_DEBUG("Websocket handles upgrade");
std::shared_ptr<crow::websocket::ConnectionImpl<
- boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>>
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>>
myConnection = std::make_shared<crow::websocket::ConnectionImpl<
- boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>>(
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>>(
req.url(), req.session, std::move(adaptor), openHandler,
messageHandler, messageExHandler, closeHandler, errorHandler);
myConnection->start(req);