Hazelcast C++ Client
Hazelcast C++ Client Library
ssl_config.h
1 /*
2  * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <string>
19 #include <vector>
20 
21 #ifdef HZ_BUILD_WITH_SSL
22 #include <boost/asio/ssl/context.hpp>
23 #endif
24 
25 #include "hazelcast/util/export.h"
26 
27 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
28 #pragma warning(push)
29 #pragma warning(disable: 4251) //for dll export
30 #endif
31 
32 namespace hazelcast {
33  namespace client {
34  namespace internal { namespace socket { class SocketFactory; }}
35  namespace config {
36 #ifdef HZ_BUILD_WITH_SSL
38  enum HAZELCAST_API ssl_protocol {
40  sslv2 = 0, // boost::asio::ssl::context_base::sslv2
41 
43  sslv3 = 3, // boost::asio::ssl::context_base::sslv3
44 
46  tlsv1 = 6, // boost::asio::ssl::context_base::tlsv1
47 
49  sslv23 = 9, // boost::asio::ssl::context_base::sslv23
50 
52  tlsv11 = 12, // boost::asio::ssl::context_base::tlsv11,
53 
55  tlsv12 = 15, // boost::asio::ssl::context_base::tlsv12
56  };
57 #endif
61  class HAZELCAST_API ssl_config {
62  public:
63  ssl_config();
64 
65 #ifdef HZ_BUILD_WITH_SSL
71  ssl_config &set_context(boost::asio::ssl::context context);
72 
78  bool is_enabled() const;
79 
87  ssl_config &set_enabled(bool is_enabled);
88 
96  ssl_config &set_protocol(ssl_protocol protocol);
97 
103  ssl_protocol get_protocol() const;
104 
110  const std::vector<std::string> &get_verify_files() const;
111 
122  ssl_config &add_verify_file(const std::string &filename);
123 
127  const std::string &get_cipher_list() const;
128 
139  ssl_config &set_cipher_list(const std::string &ciphers);
140 
141  private:
142  friend class internal::socket::SocketFactory;
143 
144  bool enabled_;
145  ssl_protocol ssl_protocol_;
146  std::vector<std::string> client_verify_files_;
147  std::string cipher_list_;
148  std::shared_ptr<boost::asio::ssl::context> ssl_context_;
149  void check_context_enabled_already() const;
150 #endif
151  };
152  }
153  }
154 }
155 
156 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
157 #pragma warning(pop)
158 #endif
159 
160 
Contains configuration parameters for ssl related behaviour.
Definition: ssl_config.h:61