From 26215025c8e21a5f844fd10654439fc23d68071c Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 3 Apr 2025 10:58:13 +0200 Subject: [PATCH] Fixed deprecated calls --- asio_compatibility.hpp | 10 ++++++++-- client_http.hpp | 2 +- client_https.hpp | 6 +++++- crypto.hpp | 2 +- server_https.hpp | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/asio_compatibility.hpp b/asio_compatibility.hpp index aa43451..e93c0cf 100644 --- a/asio_compatibility.hpp +++ b/asio_compatibility.hpp @@ -27,12 +27,18 @@ namespace SimpleWeb { #endif namespace SimpleWeb { -#if(defined(ASIO_STANDALONE) && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 +#if (defined(ASIO_STANDALONE) && ASIO_VERSION >= 103300) || BOOST_ASIO_VERSION >= 103300 + using const_buffer = asio::const_buffer; +#else + using const_buffer = asio::const_buffers_1; +#endif + +#if (defined(ASIO_STANDALONE) && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 using io_context = asio::io_context; using resolver_results = asio::ip::tcp::resolver::results_type; using async_connect_endpoint = asio::ip::tcp::endpoint; -#if(defined(ASIO_STANDALONE) && ASIO_VERSION >= 101800) || BOOST_ASIO_VERSION >= 101800 +#if (defined(ASIO_STANDALONE) && ASIO_VERSION >= 101800) || BOOST_ASIO_VERSION >= 101800 using strand = asio::strand; #else using strand = asio::strand; diff --git a/client_http.hpp b/client_http.hpp index e12fcd2..1228eb9 100644 --- a/client_http.hpp +++ b/client_http.hpp @@ -17,7 +17,7 @@ namespace SimpleWeb { public: /// Match condition for asio::read_until to match both standard and non-standard HTTP header endings. - std::pair, bool> operator()(asio::buffers_iterator begin, asio::buffers_iterator end) { + std::pair, bool> operator()(asio::buffers_iterator begin, asio::buffers_iterator end) { auto it = begin; for(; it != end; ++it) { if(*it == '\n') { diff --git a/client_https.hpp b/client_https.hpp index 86c042c..09d37ab 100644 --- a/client_https.hpp +++ b/client_https.hpp @@ -27,7 +27,7 @@ namespace SimpleWeb { Client(const std::string &server_port_path, bool verify_certificate = true, const std::string &certification_file = std::string(), const std::string &private_key_file = std::string(), const std::string &verify_file = std::string()) : ClientBase::ClientBase(server_port_path, 443), -#if(defined(ASIO_STANDALONE) && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 +#if (defined(ASIO_STANDALONE) && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 context(asio::ssl::context::tls_client) { // Disabling TLS 1.0 and 1.1 (see RFC 8996) context.set_options(asio::ssl::context::no_tlsv1); @@ -41,7 +41,11 @@ namespace SimpleWeb { } if(verify_certificate) +#if (defined(ASIO_STANDALONE) && ASIO_VERSION >= 103300) || BOOST_ASIO_VERSION >= 103300 + context.set_verify_callback(asio::ssl::host_name_verification(host)); +#else context.set_verify_callback(asio::ssl::rfc2818_verification(host)); +#endif if(verify_file.size() > 0) context.load_verify_file(verify_file); diff --git a/crypto.hpp b/crypto.hpp index 3629598..be9bfb9 100644 --- a/crypto.hpp +++ b/crypto.hpp @@ -70,7 +70,7 @@ namespace SimpleWeb { b64 = BIO_new(BIO_f_base64()); BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); // TODO: Remove in 2022 or later -#if(defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000214fL) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2080000fL) +#if (defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000214fL) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2080000fL) bio = BIO_new_mem_buf(const_cast(&base64[0]), static_cast(base64.size())); #else bio = BIO_new_mem_buf(&base64[0], static_cast(base64.size())); diff --git a/server_https.hpp b/server_https.hpp index 9b77fdc..7a02b68 100644 --- a/server_https.hpp +++ b/server_https.hpp @@ -29,7 +29,7 @@ namespace SimpleWeb { */ Server(const std::string &certification_file, const std::string &private_key_file, const std::string &verify_file = std::string()) : ServerBase::ServerBase(443), -#if(defined(ASIO_STANDALONE) && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 +#if (defined(ASIO_STANDALONE) && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 context(asio::ssl::context::tls_server) { // Disabling TLS 1.0 and 1.1 (see RFC 8996) context.set_options(asio::ssl::context::no_tlsv1);