summaryrefslogtreecommitdiff
path: root/boost/asio/ssl
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:22:41 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:22:41 +0900
commit3c1df2168531ad5580076ae08d529054689aeedd (patch)
tree941aff6f86393eecacddfec252a8508c7e8351c9 /boost/asio/ssl
parentd6a306e745acfee00e81ccaf3324a2a03516db41 (diff)
downloadboost-3c1df2168531ad5580076ae08d529054689aeedd.tar.gz
boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.bz2
boost-3c1df2168531ad5580076ae08d529054689aeedd.zip
Imported Upstream version 1.70.0upstream/1.70.0
Diffstat (limited to 'boost/asio/ssl')
-rw-r--r--boost/asio/ssl/context.hpp2
-rw-r--r--boost/asio/ssl/context_base.hpp2
-rw-r--r--boost/asio/ssl/detail/buffered_handshake_op.hpp2
-rw-r--r--boost/asio/ssl/detail/engine.hpp2
-rw-r--r--boost/asio/ssl/detail/handshake_op.hpp2
-rw-r--r--boost/asio/ssl/detail/impl/engine.ipp28
-rw-r--r--boost/asio/ssl/detail/impl/openssl_init.ipp2
-rw-r--r--boost/asio/ssl/detail/io.hpp17
-rw-r--r--boost/asio/ssl/detail/openssl_init.hpp2
-rw-r--r--boost/asio/ssl/detail/openssl_types.hpp2
-rw-r--r--boost/asio/ssl/detail/password_callback.hpp2
-rw-r--r--boost/asio/ssl/detail/read_op.hpp2
-rw-r--r--boost/asio/ssl/detail/shutdown_op.hpp14
-rw-r--r--boost/asio/ssl/detail/stream_core.hpp9
-rw-r--r--boost/asio/ssl/detail/verify_callback.hpp2
-rw-r--r--boost/asio/ssl/detail/write_op.hpp2
-rw-r--r--boost/asio/ssl/error.hpp26
-rw-r--r--boost/asio/ssl/impl/context.hpp2
-rw-r--r--boost/asio/ssl/impl/context.ipp2
-rw-r--r--boost/asio/ssl/impl/error.ipp4
-rw-r--r--boost/asio/ssl/impl/rfc2818_verification.ipp2
-rw-r--r--boost/asio/ssl/impl/src.hpp2
-rw-r--r--boost/asio/ssl/rfc2818_verification.hpp2
-rw-r--r--boost/asio/ssl/stream.hpp188
-rw-r--r--boost/asio/ssl/stream_base.hpp2
-rw-r--r--boost/asio/ssl/verify_context.hpp2
-rw-r--r--boost/asio/ssl/verify_mode.hpp2
27 files changed, 199 insertions, 127 deletions
diff --git a/boost/asio/ssl/context.hpp b/boost/asio/ssl/context.hpp
index 3d0cbfbfbc..60b92a8438 100644
--- a/boost/asio/ssl/context.hpp
+++ b/boost/asio/ssl/context.hpp
@@ -2,7 +2,7 @@
// ssl/context.hpp
// ~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/context_base.hpp b/boost/asio/ssl/context_base.hpp
index 625ccc7b5b..98fdedc2e5 100644
--- a/boost/asio/ssl/context_base.hpp
+++ b/boost/asio/ssl/context_base.hpp
@@ -2,7 +2,7 @@
// ssl/context_base.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/buffered_handshake_op.hpp b/boost/asio/ssl/detail/buffered_handshake_op.hpp
index a8963ec590..812e4d7016 100644
--- a/boost/asio/ssl/detail/buffered_handshake_op.hpp
+++ b/boost/asio/ssl/detail/buffered_handshake_op.hpp
@@ -2,7 +2,7 @@
// ssl/detail/buffered_handshake_op.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/engine.hpp b/boost/asio/ssl/detail/engine.hpp
index 01717e789e..37e4d33016 100644
--- a/boost/asio/ssl/detail/engine.hpp
+++ b/boost/asio/ssl/detail/engine.hpp
@@ -2,7 +2,7 @@
// ssl/detail/engine.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/handshake_op.hpp b/boost/asio/ssl/detail/handshake_op.hpp
index edb112eee2..846e33f253 100644
--- a/boost/asio/ssl/detail/handshake_op.hpp
+++ b/boost/asio/ssl/detail/handshake_op.hpp
@@ -2,7 +2,7 @@
// ssl/detail/handshake_op.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/impl/engine.ipp b/boost/asio/ssl/detail/impl/engine.ipp
index 9142a5df3a..cac7dfda56 100644
--- a/boost/asio/ssl/detail/impl/engine.ipp
+++ b/boost/asio/ssl/detail/impl/engine.ipp
@@ -2,7 +2,7 @@
// ssl/detail/impl/engine.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -241,14 +241,23 @@ engine::want engine::perform(int (engine::* op)(void*, std::size_t),
{
ec = boost::system::error_code(sys_error,
boost::asio::error::get_ssl_category());
- return want_nothing;
+ return pending_output_after > pending_output_before
+ ? want_output : want_nothing;
}
if (ssl_error == SSL_ERROR_SYSCALL)
{
- ec = boost::system::error_code(sys_error,
- boost::asio::error::get_system_category());
- return want_nothing;
+ if (sys_error == 0)
+ {
+ ec = boost::asio::ssl::error::unspecified_system_error;
+ }
+ else
+ {
+ ec = boost::system::error_code(sys_error,
+ boost::asio::error::get_ssl_category());
+ }
+ return pending_output_after > pending_output_before
+ ? want_output : want_nothing;
}
if (result > 0 && bytes_transferred)
@@ -269,16 +278,21 @@ engine::want engine::perform(int (engine::* op)(void*, std::size_t),
ec = boost::system::error_code();
return want_input_and_retry;
}
- else if (::SSL_get_shutdown(ssl_) & SSL_RECEIVED_SHUTDOWN)
+ else if (ssl_error == SSL_ERROR_ZERO_RETURN)
{
ec = boost::asio::error::eof;
return want_nothing;
}
- else
+ else if (ssl_error == SSL_ERROR_NONE)
{
ec = boost::system::error_code();
return want_nothing;
}
+ else
+ {
+ ec = boost::asio::ssl::error::unexpected_result;
+ return want_nothing;
+ }
}
int engine::do_accept(void*, std::size_t)
diff --git a/boost/asio/ssl/detail/impl/openssl_init.ipp b/boost/asio/ssl/detail/impl/openssl_init.ipp
index 1608138e9d..5e80dd2556 100644
--- a/boost/asio/ssl/detail/impl/openssl_init.ipp
+++ b/boost/asio/ssl/detail/impl/openssl_init.ipp
@@ -3,7 +3,7 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
-// Copyright (c) 2005-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2005-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/io.hpp b/boost/asio/ssl/detail/io.hpp
index 604148c795..f1c2e5317a 100644
--- a/boost/asio/ssl/detail/io.hpp
+++ b/boost/asio/ssl/detail/io.hpp
@@ -2,7 +2,7 @@
// ssl/detail/io.hpp
// ~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -32,6 +32,7 @@ template <typename Stream, typename Operation>
std::size_t io(Stream& next_layer, stream_core& core,
const Operation& op, boost::system::error_code& ec)
{
+ boost::system::error_code io_ec;
std::size_t bytes_transferred = 0;
do switch (op(core.engine_, ec, bytes_transferred))
{
@@ -40,8 +41,12 @@ std::size_t io(Stream& next_layer, stream_core& core,
// If the input buffer is empty then we need to read some more data from
// the underlying transport.
if (core.input_.size() == 0)
+ {
core.input_ = boost::asio::buffer(core.input_buffer_,
- next_layer.read_some(core.input_buffer_, ec));
+ next_layer.read_some(core.input_buffer_, io_ec));
+ if (!ec)
+ ec = io_ec;
+ }
// Pass the new input data to the engine.
core.input_ = core.engine_.put_input(core.input_);
@@ -54,7 +59,9 @@ std::size_t io(Stream& next_layer, stream_core& core,
// Get output data from the engine and write it to the underlying
// transport.
boost::asio::write(next_layer,
- core.engine_.get_output(core.output_buffer_), ec);
+ core.engine_.get_output(core.output_buffer_), io_ec);
+ if (!ec)
+ ec = io_ec;
// Try the operation again.
continue;
@@ -64,7 +71,9 @@ std::size_t io(Stream& next_layer, stream_core& core,
// Get output data from the engine and write it to the underlying
// transport.
boost::asio::write(next_layer,
- core.engine_.get_output(core.output_buffer_), ec);
+ core.engine_.get_output(core.output_buffer_), io_ec);
+ if (!ec)
+ ec = io_ec;
// Operation is complete. Return result to caller.
core.engine_.map_error_code(ec);
diff --git a/boost/asio/ssl/detail/openssl_init.hpp b/boost/asio/ssl/detail/openssl_init.hpp
index 05b1ea4a33..74556a233b 100644
--- a/boost/asio/ssl/detail/openssl_init.hpp
+++ b/boost/asio/ssl/detail/openssl_init.hpp
@@ -2,7 +2,7 @@
// ssl/detail/openssl_init.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/openssl_types.hpp b/boost/asio/ssl/detail/openssl_types.hpp
index c955ac6013..494287a36e 100644
--- a/boost/asio/ssl/detail/openssl_types.hpp
+++ b/boost/asio/ssl/detail/openssl_types.hpp
@@ -2,7 +2,7 @@
// ssl/detail/openssl_types.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/password_callback.hpp b/boost/asio/ssl/detail/password_callback.hpp
index 2a442f34d2..9e57e90e39 100644
--- a/boost/asio/ssl/detail/password_callback.hpp
+++ b/boost/asio/ssl/detail/password_callback.hpp
@@ -2,7 +2,7 @@
// ssl/detail/password_callback.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/read_op.hpp b/boost/asio/ssl/detail/read_op.hpp
index 31929c9474..e0322aaa62 100644
--- a/boost/asio/ssl/detail/read_op.hpp
+++ b/boost/asio/ssl/detail/read_op.hpp
@@ -2,7 +2,7 @@
// ssl/detail/read_op.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/shutdown_op.hpp b/boost/asio/ssl/detail/shutdown_op.hpp
index e98430621e..d55058af37 100644
--- a/boost/asio/ssl/detail/shutdown_op.hpp
+++ b/boost/asio/ssl/detail/shutdown_op.hpp
@@ -2,7 +2,7 @@
// ssl/detail/shutdown_op.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -42,7 +42,17 @@ public:
const boost::system::error_code& ec,
const std::size_t&) const
{
- handler(ec);
+ if (ec == boost::asio::error::eof)
+ {
+ // The engine only generates an eof when the shutdown notification has
+ // been received from the peer. This indicates that the shutdown has
+ // completed successfully, and thus need not be passed on to the handler.
+ handler(boost::system::error_code());
+ }
+ else
+ {
+ handler(ec);
+ }
}
};
diff --git a/boost/asio/ssl/detail/stream_core.hpp b/boost/asio/ssl/detail/stream_core.hpp
index fc0a6ffffc..eba283618f 100644
--- a/boost/asio/ssl/detail/stream_core.hpp
+++ b/boost/asio/ssl/detail/stream_core.hpp
@@ -2,7 +2,7 @@
// ssl/detail/stream_core.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -38,10 +38,11 @@ struct stream_core
// sufficient to hold the largest possible TLS record.
enum { max_tls_record_size = 17 * 1024 };
- stream_core(SSL_CTX* context, boost::asio::io_context& io_context)
+ template <typename Executor>
+ stream_core(SSL_CTX* context, const Executor& ex)
: engine_(context),
- pending_read_(io_context),
- pending_write_(io_context),
+ pending_read_(ex),
+ pending_write_(ex),
output_buffer_space_(max_tls_record_size),
output_buffer_(boost::asio::buffer(output_buffer_space_)),
input_buffer_space_(max_tls_record_size),
diff --git a/boost/asio/ssl/detail/verify_callback.hpp b/boost/asio/ssl/detail/verify_callback.hpp
index 1e96b2554b..b4cfdcedc0 100644
--- a/boost/asio/ssl/detail/verify_callback.hpp
+++ b/boost/asio/ssl/detail/verify_callback.hpp
@@ -2,7 +2,7 @@
// ssl/detail/verify_callback.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/detail/write_op.hpp b/boost/asio/ssl/detail/write_op.hpp
index 17ab95d67e..ec50cff54a 100644
--- a/boost/asio/ssl/detail/write_op.hpp
+++ b/boost/asio/ssl/detail/write_op.hpp
@@ -2,7 +2,7 @@
// ssl/detail/write_op.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/error.hpp b/boost/asio/ssl/error.hpp
index 4a68d71703..e9ce78718c 100644
--- a/boost/asio/ssl/error.hpp
+++ b/boost/asio/ssl/error.hpp
@@ -2,7 +2,7 @@
// ssl/error.hpp
// ~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -45,12 +45,24 @@ 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
+ stream_truncated,
+
+ /// The underlying SSL library returned a system error without providing
+ /// further information.
+ unspecified_system_error,
+
+ /// The underlying SSL library generated an unexpected result from a function
+ /// call.
+ unexpected_result
+#else // defined(GENERATING_DOCUMENTATION)
+# if (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
+ unspecified_system_error = 2,
+ unexpected_result = 3
+#endif // defined(GENERATING_DOCUMENTATION)
};
extern BOOST_ASIO_DECL
diff --git a/boost/asio/ssl/impl/context.hpp b/boost/asio/ssl/impl/context.hpp
index 8f016830f9..f9ab3ad779 100644
--- a/boost/asio/ssl/impl/context.hpp
+++ b/boost/asio/ssl/impl/context.hpp
@@ -3,7 +3,7 @@
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
-// Copyright (c) 2005-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2005-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/impl/context.ipp b/boost/asio/ssl/impl/context.ipp
index b331dea45d..0947a87564 100644
--- a/boost/asio/ssl/impl/context.ipp
+++ b/boost/asio/ssl/impl/context.ipp
@@ -3,7 +3,7 @@
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
-// Copyright (c) 2005-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2005-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/impl/error.ipp b/boost/asio/ssl/impl/error.ipp
index a359619765..d77c051c9e 100644
--- a/boost/asio/ssl/impl/error.ipp
+++ b/boost/asio/ssl/impl/error.ipp
@@ -2,7 +2,7 @@
// ssl/impl/error.ipp
// ~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -77,6 +77,8 @@ public:
switch (value)
{
case stream_truncated: return "stream truncated";
+ case unspecified_system_error: return "unspecified system error";
+ case unexpected_result: return "unexpected result";
default: return "asio.ssl.stream error";
}
}
diff --git a/boost/asio/ssl/impl/rfc2818_verification.ipp b/boost/asio/ssl/impl/rfc2818_verification.ipp
index 63ce663bdc..3720509258 100644
--- a/boost/asio/ssl/impl/rfc2818_verification.ipp
+++ b/boost/asio/ssl/impl/rfc2818_verification.ipp
@@ -2,7 +2,7 @@
// ssl/impl/rfc2818_verification.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/impl/src.hpp b/boost/asio/ssl/impl/src.hpp
index 2e8859ea2b..4f965ed4ab 100644
--- a/boost/asio/ssl/impl/src.hpp
+++ b/boost/asio/ssl/impl/src.hpp
@@ -2,7 +2,7 @@
// impl/ssl/src.hpp
// ~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/rfc2818_verification.hpp b/boost/asio/ssl/rfc2818_verification.hpp
index 047688b007..1e4e411658 100644
--- a/boost/asio/ssl/rfc2818_verification.hpp
+++ b/boost/asio/ssl/rfc2818_verification.hpp
@@ -2,7 +2,7 @@
// ssl/rfc2818_verification.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/stream.hpp b/boost/asio/ssl/stream.hpp
index 1acaceea45..2ae8c13a4a 100644
--- a/boost/asio/ssl/stream.hpp
+++ b/boost/asio/ssl/stream.hpp
@@ -2,7 +2,7 @@
// ssl/stream.hpp
// ~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -20,6 +20,7 @@
#include <boost/asio/async_result.hpp>
#include <boost/asio/detail/buffer_sequence_adapter.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
+#include <boost/asio/detail/non_const_lvalue.hpp>
#include <boost/asio/detail/noncopyable.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/ssl/context.hpp>
@@ -52,9 +53,9 @@ namespace ssl {
* @par Example
* To use the SSL stream template with an ip::tcp::socket, you would write:
* @code
- * boost::asio::io_context io_context;
+ * boost::asio::io_context my_context;
* boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23);
- * boost::asio::ssl::stream<asio:ip::tcp::socket> sock(io_context, ctx);
+ * boost::asio::ssl::stream<asio:ip::tcp::socket> sock(my_context, ctx);
* @endcode
*
* @par Concepts:
@@ -97,16 +98,14 @@ public:
template <typename Arg>
stream(Arg&& arg, context& ctx)
: next_layer_(BOOST_ASIO_MOVE_CAST(Arg)(arg)),
- core_(ctx.native_handle(),
- next_layer_.lowest_layer().get_executor().context())
+ core_(ctx.native_handle(), next_layer_.lowest_layer().get_executor())
{
}
#else // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
template <typename Arg>
stream(Arg& arg, context& ctx)
: next_layer_(arg),
- core_(ctx.native_handle(),
- next_layer_.lowest_layer().get_executor().context())
+ core_(ctx.native_handle(), next_layer_.lowest_layer().get_executor())
{
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
@@ -132,22 +131,6 @@ public:
return next_layer_.lowest_layer().get_executor();
}
-#if !defined(BOOST_ASIO_NO_DEPRECATED)
- /// (Deprecated: Use get_executor().) Get the io_context associated with the
- /// object.
- boost::asio::io_context& get_io_context()
- {
- return next_layer_.lowest_layer().get_io_context();
- }
-
- /// (Deprecated: Use get_executor().) Get the io_context associated with the
- /// object.
- boost::asio::io_context& get_io_service()
- {
- return next_layer_.lowest_layer().get_io_service();
- }
-#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
-
/// Get the underlying implementation in the native type.
/**
* This function may be used to obtain the underlying implementation of the
@@ -159,7 +142,7 @@ public:
* suitable for passing to functions such as @c SSL_get_verify_result and
* @c SSL_get_peer_certificate:
* @code
- * boost::asio::ssl::stream<asio:ip::tcp::socket> sock(io_context, ctx);
+ * boost::asio::ssl::stream<asio:ip::tcp::socket> sock(my_context, ctx);
*
* // ... establish connection and perform handshake ...
*
@@ -454,17 +437,9 @@ public:
async_handshake(handshake_type type,
BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler)
{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a HandshakeHandler.
- BOOST_ASIO_HANDSHAKE_HANDLER_CHECK(HandshakeHandler, handler) type_check;
-
- boost::asio::async_completion<HandshakeHandler,
- void (boost::system::error_code)> init(handler);
-
- detail::async_io(next_layer_, core_,
- detail::handshake_op(type), init.completion_handler);
-
- return init.result.get();
+ return async_initiate<HandshakeHandler,
+ void (boost::system::error_code)>(
+ initiate_async_handshake(), handler, this, type);
}
/// Start an asynchronous SSL handshake.
@@ -494,19 +469,9 @@ public:
async_handshake(handshake_type type, const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler)
{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a BufferedHandshakeHandler.
- BOOST_ASIO_BUFFERED_HANDSHAKE_HANDLER_CHECK(
- BufferedHandshakeHandler, handler) type_check;
-
- boost::asio::async_completion<BufferedHandshakeHandler,
- void (boost::system::error_code, std::size_t)> init(handler);
-
- detail::async_io(next_layer_, core_,
- detail::buffered_handshake_op<ConstBufferSequence>(type, buffers),
- init.completion_handler);
-
- return init.result.get();
+ return async_initiate<BufferedHandshakeHandler,
+ void (boost::system::error_code, std::size_t)>(
+ initiate_async_buffered_handshake(), handler, this, type, buffers);
}
/// Shut down SSL on the stream.
@@ -553,17 +518,9 @@ public:
void (boost::system::error_code))
async_shutdown(BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler)
{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ShutdownHandler.
- BOOST_ASIO_SHUTDOWN_HANDLER_CHECK(ShutdownHandler, handler) type_check;
-
- boost::asio::async_completion<ShutdownHandler,
- void (boost::system::error_code)> init(handler);
-
- detail::async_io(next_layer_, core_, detail::shutdown_op(),
- init.completion_handler);
-
- return init.result.get();
+ return async_initiate<ShutdownHandler,
+ void (boost::system::error_code)>(
+ initiate_async_shutdown(), handler, this);
}
/// Write some data to the stream.
@@ -644,18 +601,9 @@ public:
async_write_some(const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a WriteHandler.
- BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
-
- boost::asio::async_completion<WriteHandler,
- void (boost::system::error_code, std::size_t)> init(handler);
-
- detail::async_io(next_layer_, core_,
- detail::write_op<ConstBufferSequence>(buffers),
- init.completion_handler);
-
- return init.result.get();
+ return async_initiate<WriteHandler,
+ void (boost::system::error_code, std::size_t)>(
+ initiate_async_write_some(), handler, this, buffers);
}
/// Read some data from the stream.
@@ -736,21 +684,97 @@ public:
async_read_some(const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+ return async_initiate<ReadHandler,
+ void (boost::system::error_code, std::size_t)>(
+ initiate_async_read_some(), handler, this, buffers);
+ }
- boost::asio::async_completion<ReadHandler,
- void (boost::system::error_code, std::size_t)> init(handler);
+private:
+ struct initiate_async_handshake
+ {
+ template <typename HandshakeHandler>
+ void operator()(BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler,
+ stream* self, handshake_type type) const
+ {
+ // If you get an error on the following line it means that your handler
+ // does not meet the documented type requirements for a HandshakeHandler.
+ BOOST_ASIO_HANDSHAKE_HANDLER_CHECK(HandshakeHandler, handler) type_check;
+
+ boost::asio::detail::non_const_lvalue<HandshakeHandler> handler2(handler);
+ detail::async_io(self->next_layer_, self->core_,
+ detail::handshake_op(type), handler2.value);
+ }
+ };
- detail::async_io(next_layer_, core_,
- detail::read_op<MutableBufferSequence>(buffers),
- init.completion_handler);
+ struct initiate_async_buffered_handshake
+ {
+ template <typename BufferedHandshakeHandler, typename ConstBufferSequence>
+ void operator()(BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler,
+ stream* self, handshake_type type,
+ const ConstBufferSequence& buffers) const
+ {
+ // If you get an error on the following line it means that your
+ // handler does not meet the documented type requirements for a
+ // BufferedHandshakeHandler.
+ BOOST_ASIO_BUFFERED_HANDSHAKE_HANDLER_CHECK(
+ BufferedHandshakeHandler, handler) type_check;
+
+ boost::asio::detail::non_const_lvalue<
+ BufferedHandshakeHandler> handler2(handler);
+ detail::async_io(self->next_layer_, self->core_,
+ detail::buffered_handshake_op<ConstBufferSequence>(type, buffers),
+ handler2.value);
+ }
+ };
- return init.result.get();
- }
+ struct initiate_async_shutdown
+ {
+ template <typename ShutdownHandler>
+ void operator()(BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler,
+ stream* self) const
+ {
+ // If you get an error on the following line it means that your handler
+ // does not meet the documented type requirements for a ShutdownHandler.
+ BOOST_ASIO_HANDSHAKE_HANDLER_CHECK(ShutdownHandler, handler) type_check;
+
+ boost::asio::detail::non_const_lvalue<ShutdownHandler> handler2(handler);
+ detail::async_io(self->next_layer_, self->core_,
+ detail::shutdown_op(), handler2.value);
+ }
+ };
+
+ struct initiate_async_write_some
+ {
+ template <typename WriteHandler, typename ConstBufferSequence>
+ void operator()(BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
+ stream* self, const ConstBufferSequence& buffers) const
+ {
+ // If you get an error on the following line it means that your handler
+ // does not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ boost::asio::detail::non_const_lvalue<WriteHandler> handler2(handler);
+ detail::async_io(self->next_layer_, self->core_,
+ detail::write_op<ConstBufferSequence>(buffers), handler2.value);
+ }
+ };
+
+ struct initiate_async_read_some
+ {
+ template <typename ReadHandler, typename MutableBufferSequence>
+ void operator()(BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
+ stream* self, const MutableBufferSequence& buffers) const
+ {
+ // If you get an error on the following line it means that your handler
+ // does not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ boost::asio::detail::non_const_lvalue<ReadHandler> handler2(handler);
+ detail::async_io(self->next_layer_, self->core_,
+ detail::read_op<MutableBufferSequence>(buffers), handler2.value);
+ }
+ };
-private:
Stream next_layer_;
detail::stream_core core_;
};
diff --git a/boost/asio/ssl/stream_base.hpp b/boost/asio/ssl/stream_base.hpp
index 5847214894..0fefde54f1 100644
--- a/boost/asio/ssl/stream_base.hpp
+++ b/boost/asio/ssl/stream_base.hpp
@@ -2,7 +2,7 @@
// ssl/stream_base.hpp
// ~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/verify_context.hpp b/boost/asio/ssl/verify_context.hpp
index c5fdaf4adb..952ec917cd 100644
--- a/boost/asio/ssl/verify_context.hpp
+++ b/boost/asio/ssl/verify_context.hpp
@@ -2,7 +2,7 @@
// ssl/verify_context.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/asio/ssl/verify_mode.hpp b/boost/asio/ssl/verify_mode.hpp
index 9ae6050442..0dcf18af96 100644
--- a/boost/asio/ssl/verify_mode.hpp
+++ b/boost/asio/ssl/verify_mode.hpp
@@ -2,7 +2,7 @@
// ssl/verify_mode.hpp
// ~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)