Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
ssl_config.h
1/*
2 * Copyright (c) 2008-2025, 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
32namespace hazelcast {
33namespace client {
34namespace internal {
35namespace socket {
36class SocketFactory;
37}
38} // namespace internal
39namespace config {
40#ifdef HZ_BUILD_WITH_SSL
42enum HAZELCAST_API ssl_protocol
43{
45 sslv2 = 0, // boost::asio::ssl::context_base::sslv2
46
48 sslv3 = 3, // boost::asio::ssl::context_base::sslv3
49
51 tlsv1 = 6, // boost::asio::ssl::context_base::tlsv1
52
54 sslv23 = 9, // boost::asio::ssl::context_base::sslv23
55
57 tlsv11 = 12, // boost::asio::ssl::context_base::tlsv11,
58
60 tlsv12 = 15, // boost::asio::ssl::context_base::tlsv12
61};
62#endif
66class HAZELCAST_API ssl_config
67{
68public:
69 ssl_config();
70
71#ifdef HZ_BUILD_WITH_SSL
77 ssl_config& set_context(boost::asio::ssl::context context);
78
84 bool is_enabled() const;
85
93 ssl_config& set_enabled(bool is_enabled);
94
102 ssl_config& set_protocol(ssl_protocol protocol);
103
109 ssl_protocol get_protocol() const;
110
117 const std::vector<std::string>& get_verify_files() const;
118
131 ssl_config& add_verify_file(const std::string& filename);
132
136 const std::string& get_cipher_list() const;
137
151 ssl_config& set_cipher_list(const std::string& ciphers);
152
153private:
154 friend class internal::socket::SocketFactory;
155
156 bool enabled_;
157 ssl_protocol ssl_protocol_;
158 std::vector<std::string> client_verify_files_;
159 std::string cipher_list_;
160 std::shared_ptr<boost::asio::ssl::context> ssl_context_;
161 void check_context_enabled_already() const;
162#endif
163};
164} // namespace config
165} // namespace client
166} // namespace hazelcast
167
168#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
169#pragma warning(pop)
170#endif