Line data Source code
1 : // Copyright (c) 2012-2019 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // https://snapwebsites.org/project/eventdispatcher
4 : // contact@m2osw.com
5 : //
6 : // This program is free software; you can redistribute it and/or modify
7 : // it under the terms of the GNU General Public License as published by
8 : // the Free Software Foundation; either version 2 of the License, or
9 : // (at your option) any later version.
10 : //
11 : // This program is distributed in the hope that it will be useful,
12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License
17 : // along with this program; if not, write to the Free Software
18 : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 : #pragma once
20 :
21 : /** \file
22 : * \brief Event dispatch class.
23 : *
24 : * Class used to handle events.
25 : */
26 :
27 : // make sure we use OpenSSL with multi-thread support
28 : // (TODO: move to .cpp once we have the SSL flags worked on!)
29 : #define OPENSSL_THREAD_DEFINES
30 :
31 :
32 : // C++ lib
33 : //
34 : #include <string>
35 :
36 :
37 : // OpenSSL lib
38 : //
39 : // TODO: create our own set of flags to avoid this header in the .h
40 : #include <openssl/ssl.h>
41 :
42 :
43 :
44 : namespace ed
45 : {
46 :
47 :
48 :
49 0 : class tcp_bio_options
50 : {
51 : public:
52 : typedef std::uint32_t ssl_options_t;
53 : typedef size_t verification_depth_t;
54 :
55 : static constexpr verification_depth_t MAX_VERIFICATION_DEPTH = 100;
56 : static constexpr ssl_options_t DEFAULT_SSL_OPTIONS = SSL_OP_NO_SSLv2
57 : | SSL_OP_NO_SSLv3
58 : | SSL_OP_NO_TLSv1
59 : | SSL_OP_NO_COMPRESSION;
60 :
61 : tcp_bio_options();
62 :
63 : void set_verification_depth(verification_depth_t depth);
64 : verification_depth_t get_verification_depth() const;
65 :
66 : void set_ssl_options(ssl_options_t ssl_options);
67 : ssl_options_t get_ssl_options() const;
68 :
69 : void set_ssl_certificate_path(std::string const path);
70 : std::string const & get_ssl_certificate_path() const;
71 : void set_keepalive(bool keepalive = true);
72 : bool get_keepalive() const;
73 :
74 : void set_sni(bool sni = true);
75 : bool get_sni() const;
76 :
77 : void set_host(std::string const & host);
78 : std::string const & get_host() const;
79 :
80 : private:
81 : verification_depth_t f_verification_depth = 4;
82 : ssl_options_t f_ssl_options = DEFAULT_SSL_OPTIONS;
83 : std::string f_ssl_certificate_path = std::string("/etc/ssl/certs");
84 : bool f_keepalive = true;
85 : bool f_sni = true;
86 : std::string f_host = std::string();
87 : };
88 :
89 :
90 :
91 : } // namespace ed
92 : // vim: ts=4 sw=4 et
|