aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src/net_ssl.cpp
diff options
context:
space:
mode:
authorLee *!* Clagett <code@leeclagett.com>2024-12-17 16:40:15 -0500
committerLee *!* Clagett <code@leeclagett.com>2025-02-14 13:29:57 -0500
commit01bcd52924244ec8d2a24c10fcef8959289d09ff (patch)
tree7aa82581901a978c3c7ba3b0f50ac8c84f753945 /contrib/epee/src/net_ssl.cpp
parent23a11d851adef30aea1888da0a7dd23936c81ec1 (diff)
downloadmonzero-core-01bcd52924244ec8d2a24c10fcef8959289d09ff.tar.gz
monzero-core-01bcd52924244ec8d2a24c10fcef8959289d09ff.tar.xz
monzero-core-01bcd52924244ec8d2a24c10fcef8959289d09ff.zip
Fix build with boost ASIO 0.87. Support boost 1.66+
Diffstat (limited to 'contrib/epee/src/net_ssl.cpp')
-rw-r--r--contrib/epee/src/net_ssl.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp
index 9200796a8..aef37844e 100644
--- a/contrib/epee/src/net_ssl.cpp
+++ b/contrib/epee/src/net_ssl.cpp
@@ -29,6 +29,7 @@
#include <string.h>
#include <thread>
+#include <boost/asio/post.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/cerrno.hpp>
#include <boost/filesystem/operations.hpp>
@@ -45,6 +46,13 @@
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.ssl"
+
+#if BOOST_VERSION >= 107300
+ #define MONERO_HOSTNAME_VERIFY boost::asio::ssl::host_name_verification
+#else
+ #define MONERO_HOSTNAME_VERIFY boost::asio::ssl::rfc2818_verification
+#endif
+
// openssl genrsa -out /tmp/KEY 4096
// openssl req -new -key /tmp/KEY -out /tmp/REQ
// openssl x509 -req -days 999999 -sha256 -in /tmp/REQ -signkey /tmp/KEY -out /tmp/CERT
@@ -526,7 +534,7 @@ void ssl_options_t::configure(
// preverified means it passed system or user CA check. System CA is never loaded
// when fingerprints are whitelisted.
const bool verified = preverified &&
- (verification != ssl_verification_t::system_ca || host.empty() || boost::asio::ssl::rfc2818_verification(host)(preverified, ctx));
+ (verification != ssl_verification_t::system_ca || host.empty() || MONERO_HOSTNAME_VERIFY(host)(preverified, ctx));
if (!verified && !has_fingerprint(ctx))
{
@@ -544,6 +552,7 @@ void ssl_options_t::configure(
}
bool ssl_options_t::handshake(
+ boost::asio::io_context& io_context,
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
boost::asio::ssl::stream_base::handshake_type type,
boost::asio::const_buffer buffer,
@@ -555,12 +564,11 @@ bool ssl_options_t::handshake(
auto start_handshake = [&]{
using ec_t = boost::system::error_code;
using timer_t = boost::asio::steady_timer;
- using strand_t = boost::asio::io_service::strand;
+ using strand_t = boost::asio::io_context::strand;
using socket_t = boost::asio::ip::tcp::socket;
- auto &io_context = GET_IO_SERVICE(socket);
if (io_context.stopped())
- io_context.reset();
+ io_context.restart();
strand_t strand(io_context);
timer_t deadline(io_context, timeout);
@@ -595,13 +603,13 @@ bool ssl_options_t::handshake(
state.result = ec;
if (!state.cancel_handshake) {
state.cancel_timer = true;
- ec_t ec;
- deadline.cancel(ec);
+ deadline.cancel();
}
};
deadline.async_wait(on_timer);
- strand.post(
+ boost::asio::post(
+ strand,
[&]{
socket.async_handshake(
type,