diff --git a/doc/api_ref/tls.rst b/doc/api_ref/tls.rst index 1c47fc338ff..a8d4c819942 100644 --- a/doc/api_ref/tls.rst +++ b/doc/api_ref/tls.rst @@ -1191,7 +1191,13 @@ TLS Stream :cpp:class:`TLS::Stream` offers a Boost.Asio compatible wrapper around :cpp:class:`TLS::Client` and :cpp:class:`TLS::Server`. It can be used as an alternative to Boost.Asio's `ssl::stream <https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/reference/ssl__stream.html>`_ with minor adjustments to the using code. -It offers the following interface: + +To use the asio stream wrapper, a relatively recent version of boost is required. +Include ``botan/boost_compat.h`` and check that ``BOTAN_FOUND_COMPATIBLE_BOOST_VERSION`` +is defined before including ``botan/asio_stream.h`` to be ensure compatibility at +compile time of your application. + +The asio Stream offers the following interface: .. cpp:class:: template <class StreamLayer, class ChannelT> TLS::Stream diff --git a/src/examples/tls_stream_client.cpp b/src/examples/tls_stream_client.cpp index f617f5063e6..e880ec401eb 100644 --- a/src/examples/tls_stream_client.cpp +++ b/src/examples/tls_stream_client.cpp @@ -1,14 +1,17 @@ #include <iostream> -#include <botan/asio_stream.h> -#include <botan/auto_rng.h> -#include <botan/certstor_system.h> -#include <botan/tls.h> +#include <botan/boost_compat.h> +#if defined(BOTAN_FOUND_COMPATIBLE_BOOST_VERSION) -#include <boost/asio.hpp> -#include <boost/beast.hpp> -#include <boost/bind.hpp> -#include <utility> + #include <botan/asio_stream.h> + #include <botan/auto_rng.h> + #include <botan/certstor_system.h> + #include <botan/tls.h> + + #include <boost/asio.hpp> + #include <boost/beast.hpp> + #include <boost/bind.hpp> + #include <utility> namespace http = boost::beast::http; namespace ap = boost::asio::placeholders; @@ -113,3 +116,12 @@ int main() { return 0; } + +#else + +int main() { + std::cout << "Your boost version is too old, sorry.\n"; + return 1; +} + +#endif