Skip to content

Supported alternative TLS library. #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions include/mqtt/async_client.hpp

Large diffs are not rendered by default.

114 changes: 52 additions & 62 deletions include/mqtt/client.hpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions include/mqtt/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <boost/system/error_code.hpp>
#include <boost/assert.hpp>

#include <mqtt/tls.hpp>
#include <mqtt/namespace.hpp>
#include <mqtt/attributes.hpp>
#include <mqtt/any.hpp>
Expand Down
45 changes: 18 additions & 27 deletions include/mqtt/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,8 @@
#include <boost/asio.hpp>

#include <mqtt/namespace.hpp>

#if defined(MQTT_USE_TLS)
#include <boost/asio/ssl.hpp>
#endif // defined(MQTT_USE_TLS)

#include <mqtt/tcp_endpoint.hpp>

#if defined(MQTT_USE_WS)
#include <mqtt/ws_endpoint.hpp>
#endif // defined(MQTT_USE_WS)

#include <mqtt/endpoint.hpp>
#include <mqtt/null_strand.hpp>
#include <mqtt/move.hpp>
Expand Down Expand Up @@ -212,7 +203,7 @@ template <
>
class server_tls {
public:
using socket_t = tcp_endpoint<as::ssl::stream<as::ip::tcp::socket>, Strand>;
using socket_t = tcp_endpoint<tls::stream<as::ip::tcp::socket>, Strand>;
using endpoint_t = callable_overlay<server_endpoint<Mutex, LockGuard, PacketIdBytes>>;

/**
Expand All @@ -230,7 +221,7 @@ class server_tls {
template <typename AsioEndpoint, typename AcceptorConfig>
server_tls(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc_accept,
as::io_context& ioc_con,
AcceptorConfig&& config)
Expand All @@ -246,23 +237,23 @@ class server_tls {
template <typename AsioEndpoint>
server_tls(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc_accept,
as::io_context& ioc_con)
: server_tls(std::forward<AsioEndpoint>(ep), force_move(ctx), ioc_accept, ioc_con, [](as::ip::tcp::acceptor&) {}) {}

template <typename AsioEndpoint, typename AcceptorConfig>
server_tls(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc,
AcceptorConfig&& config)
: server_tls(std::forward<AsioEndpoint>(ep), force_move(ctx), ioc, ioc, std::forward<AcceptorConfig>(config)) {}

template <typename AsioEndpoint>
server_tls(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc)
: server_tls(std::forward<AsioEndpoint>(ep), force_move(ctx), ioc, ioc, [](as::ip::tcp::acceptor&) {}) {}

Expand Down Expand Up @@ -349,15 +340,15 @@ class server_tls {
* @brief Get boost asio ssl context.
* @return ssl context
*/
as::ssl::context& get_ssl_context() {
tls::context& get_ssl_context() {
return ctx_;
}

/**
* @brief Get boost asio ssl context.
* @return ssl context
*/
as::ssl::context const& get_ssl_context() const {
tls::context const& get_ssl_context() const {
return ctx_;
}

Expand Down Expand Up @@ -393,7 +384,7 @@ class server_tls {
);
auto ps = socket.get();
ps->async_handshake(
as::ssl::stream_base::server,
tls::stream_base::server,
[this, socket = force_move(socket), tim, underlying_finished]
(error_code ec) mutable {
*underlying_finished = true;
Expand All @@ -419,7 +410,7 @@ class server_tls {
bool close_request_{false};
accept_handler h_accept_;
error_handler h_error_;
as::ssl::context ctx_;
tls::context ctx_;
protocol_version version_ = protocol_version::undetermined;
std::chrono::steady_clock::duration underlying_connect_timeout_ = std::chrono::seconds(10);
};
Expand Down Expand Up @@ -701,7 +692,7 @@ template <
>
class server_tls_ws {
public:
using socket_t = ws_endpoint<as::ssl::stream<as::ip::tcp::socket>, Strand>;
using socket_t = ws_endpoint<tls::stream<as::ip::tcp::socket>, Strand>;
using endpoint_t = callable_overlay<server_endpoint<Mutex, LockGuard, PacketIdBytes>>;

/**
Expand All @@ -719,7 +710,7 @@ class server_tls_ws {
template <typename AsioEndpoint, typename AcceptorConfig>
server_tls_ws(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc_accept,
as::io_context& ioc_con,
AcceptorConfig&& config)
Expand All @@ -735,23 +726,23 @@ class server_tls_ws {
template <typename AsioEndpoint>
server_tls_ws(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc_accept,
as::io_context& ioc_con)
: server_tls_ws(std::forward<AsioEndpoint>(ep), force_move(ctx), ioc_accept, ioc_con, [](as::ip::tcp::acceptor&) {}) {}

template <typename AsioEndpoint, typename AcceptorConfig>
server_tls_ws(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc,
AcceptorConfig&& config)
: server_tls_ws(std::forward<AsioEndpoint>(ep), force_move(ctx), ioc, ioc, std::forward<AcceptorConfig>(config)) {}

template <typename AsioEndpoint>
server_tls_ws(
AsioEndpoint&& ep,
as::ssl::context&& ctx,
tls::context&& ctx,
as::io_context& ioc)
: server_tls_ws(std::forward<AsioEndpoint>(ep), force_move(ctx), ioc, ioc, [](as::ip::tcp::acceptor&) {}) {}

Expand Down Expand Up @@ -838,15 +829,15 @@ class server_tls_ws {
* @brief Get boost asio ssl context.
* @return ssl context
*/
as::ssl::context& get_ssl_context() {
tls::context& get_ssl_context() {
return ctx_;
}

/**
* @brief Get boost asio ssl context.
* @return ssl context
*/
as::ssl::context const& get_ssl_context() const {
tls::context const& get_ssl_context() const {
return ctx_;
}

Expand Down Expand Up @@ -883,7 +874,7 @@ class server_tls_ws {

auto ps = socket.get();
ps->next_layer().async_handshake(
as::ssl::stream_base::server,
tls::stream_base::server,
[this, socket = force_move(socket), tim, underlying_finished]
(error_code ec) mutable {
if (ec) {
Expand Down Expand Up @@ -987,7 +978,7 @@ class server_tls_ws {
bool close_request_{false};
accept_handler h_accept_;
error_handler h_error_;
as::ssl::context ctx_;
tls::context ctx_;
protocol_version version_ = protocol_version::undetermined;
std::chrono::steady_clock::duration underlying_connect_timeout_ = std::chrono::seconds(10);
};
Expand Down
Loading