rippled
Loading...
Searching...
No Matches
WorkSSL.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2020 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpld/app/misc/detail/WorkSSL.h>
21
22namespace ripple {
23namespace detail {
24
26 std::string const& host,
27 std::string const& path,
28 std::string const& port,
29 boost::asio::io_context& ios,
31 Config const& config,
32 endpoint_type const& lastEndpoint,
33 bool lastStatus,
35 : WorkBase(host, path, port, ios, lastEndpoint, lastStatus, cb)
36 , context_(
37 config.SSL_VERIFY_DIR,
38 config.SSL_VERIFY_FILE,
39 config.SSL_VERIFY,
40 j,
41 boost::asio::ssl::context::tlsv12_client)
42 , stream_(socket_, context_.context())
43{
45 if (ec)
46 Throw<std::runtime_error>(
47 boost::str(boost::format("preConnectVerify: %s") % ec.message()));
48}
49
50void
52{
53 auto err = ec ? ec : context_.postConnectVerify(stream_, host_);
54 if (err)
55 return fail(err);
56
57 stream_.async_handshake(
58 boost::asio::ssl::stream_base::client,
59 boost::asio::bind_executor(
60 strand_,
64 std::placeholders::_1)));
65}
66
67void
69{
70 if (ec)
71 return fail(ec);
72
73 onStart();
74}
75
76} // namespace detail
77
78} // namespace ripple
T bind(T... args)
A generic endpoint for log messages.
Definition Journal.h:60
boost::system::error_code preConnectVerify(T &strm, std::string const &host)
invoked before connect/async_connect on an ssl stream to setup name verification.
boost::system::error_code postConnectVerify(T &strm, std::string const &host)
invoked after connect/async_connect but before sending data on an ssl stream - to setup name verifica...
boost::asio::ip::tcp::endpoint endpoint_type
Definition WorkBase.h:44
boost::system::error_code error_code
Definition WorkBase.h:43
boost::asio::strand< boost::asio::io_context::executor_type > strand_
Definition WorkBase.h:62
void fail(error_code const &ec)
Definition WorkBase.h:194
void onHandshake(error_code const &ec)
Definition WorkSSL.cpp:68
void onConnect(error_code const &ec)
Definition WorkSSL.cpp:51
HTTPClientSSLContext context_
Definition WorkSSL.h:47
WorkSSL(std::string const &host, std::string const &path, std::string const &port, boost::asio::io_context &ios, beast::Journal j, Config const &config, endpoint_type const &lastEndpoint, bool lastStatus, callback_type cb)
Definition WorkSSL.cpp:25
stream_type stream_
Definition WorkSSL.h:48
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25