rippled
WorkSSL.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2016 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 #ifndef RIPPLE_APP_MISC_DETAIL_WORKSSL_H_INCLUDED
21 #define RIPPLE_APP_MISC_DETAIL_WORKSSL_H_INCLUDED
22 
23 #include <ripple/app/misc/detail/WorkBase.h>
24 #include <ripple/basics/contract.h>
25 #include <ripple/core/Config.h>
26 #include <ripple/net/HTTPClientSSLContext.h>
27 #include <boost/asio/ssl.hpp>
28 #include <boost/format.hpp>
29 
30 #include <functional>
31 
32 namespace ripple {
33 
34 namespace detail {
35 
36 // Work over SSL
37 class WorkSSL : public WorkBase<WorkSSL>,
38  public std::enable_shared_from_this<WorkSSL>
39 {
40  friend class WorkBase<WorkSSL>;
41 
42 private:
43  using stream_type = boost::asio::ssl::stream<socket_type&>;
44 
47 
48 public:
49  WorkSSL(
50  std::string const& host,
51  std::string const& path,
52  std::string const& port,
53  boost::asio::io_service& ios,
55  Config const& config,
56  endpoint_type const& lastEndpoint,
57  bool lastStatus,
58  callback_type cb);
59  ~WorkSSL() = default;
60 
61 private:
64  {
65  return stream_;
66  }
67 
68  void
69  onConnect(error_code const& ec);
70 
71  void
72  onHandshake(error_code const& ec);
73 };
74 
75 } // namespace detail
76 
77 } // namespace ripple
78 
79 #endif
ripple::detail::WorkBase< WorkSSL >::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: WorkBase.h:44
ripple::detail::WorkSSL::stream_type
boost::asio::ssl::stream< socket_type & > stream_type
Definition: WorkSSL.h:43
ripple::detail::WorkSSL::~WorkSSL
~WorkSSL()=default
std::string
STL class.
functional
ripple::detail::WorkSSL
Definition: WorkSSL.h:37
ripple::detail::WorkSSL::onHandshake
void onHandshake(error_code const &ec)
Definition: WorkSSL.cpp:59
std::function< void(error_code const &, endpoint_type const &, response_type &&)>
ripple::detail::WorkSSL::stream
stream_type & stream()
Definition: WorkSSL.h:63
ripple::detail::WorkSSL::stream_
stream_type stream_
Definition: WorkSSL.h:46
ripple::detail::WorkSSL::context_
HTTPClientSSLContext context_
Definition: WorkSSL.h:45
ripple::Config
Definition: Config.h:89
std::enable_shared_from_this
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::detail::WorkSSL::onConnect
void onConnect(error_code const &ec)
Definition: WorkSSL.cpp:46
ripple::HTTPClientSSLContext
Definition: HTTPClientSSLContext.h:34
ripple::detail::WorkBase
Definition: WorkBase.h:40
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::detail::WorkSSL::WorkSSL
WorkSSL(std::string const &host, std::string const &path, std::string const &port, boost::asio::io_service &ios, beast::Journal j, Config const &config, endpoint_type const &lastEndpoint, bool lastStatus, callback_type cb)
Definition: WorkSSL.cpp:25
ripple::detail::WorkBase< WorkSSL >::error_code
boost::system::error_code error_code
Definition: WorkBase.h:43