2 // ssl/context_base.hpp
3 // ~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_SSL_CONTEXT_BASE_HPP
12 #define BOOST_ASIO_SSL_CONTEXT_BASE_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/ssl/detail/openssl_types.hpp>
21 #include <boost/asio/detail/push_options.hpp>
27 /// The context_base class is used as a base for the basic_context class
28 /// template so that we have a common place to define various enums.
32 /// Different methods supported by a context.
35 /// Generic SSL version 2.
38 /// SSL version 2 client.
41 /// SSL version 2 server.
44 /// Generic SSL version 3.
47 /// SSL version 3 client.
50 /// SSL version 3 server.
53 /// Generic TLS version 1.
56 /// TLS version 1 client.
59 /// TLS version 1 server.
71 /// Generic TLS version 1.1.
74 /// TLS version 1.1 client.
77 /// TLS version 1.1 server.
80 /// Generic TLS version 1.2.
83 /// TLS version 1.2 client.
86 /// TLS version 1.2 server.
89 /// Generic TLS version 1.3.
92 /// TLS version 1.3 client.
95 /// TLS version 1.3 server.
108 /// Bitmask type for SSL options.
109 typedef long options;
111 #if defined(GENERATING_DOCUMENTATION)
112 /// Implement various bug workarounds.
113 static const long default_workarounds = implementation_defined;
115 /// Always create a new key when using tmp_dh parameters.
116 static const long single_dh_use = implementation_defined;
119 static const long no_sslv2 = implementation_defined;
122 static const long no_sslv3 = implementation_defined;
125 static const long no_tlsv1 = implementation_defined;
127 /// Disable TLS v1.1.
128 static const long no_tlsv1_1 = implementation_defined;
130 /// Disable TLS v1.2.
131 static const long no_tlsv1_2 = implementation_defined;
133 /// Disable TLS v1.3.
134 static const long no_tlsv1_3 = implementation_defined;
136 /// Disable compression. Compression is disabled by default.
137 static const long no_compression = implementation_defined;
139 BOOST_ASIO_STATIC_CONSTANT(long, default_workarounds = SSL_OP_ALL);
140 BOOST_ASIO_STATIC_CONSTANT(long, single_dh_use = SSL_OP_SINGLE_DH_USE);
141 BOOST_ASIO_STATIC_CONSTANT(long, no_sslv2 = SSL_OP_NO_SSLv2);
142 BOOST_ASIO_STATIC_CONSTANT(long, no_sslv3 = SSL_OP_NO_SSLv3);
143 BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1 = SSL_OP_NO_TLSv1);
144 # if defined(SSL_OP_NO_TLSv1_1)
145 BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_1 = SSL_OP_NO_TLSv1_1);
146 # else // defined(SSL_OP_NO_TLSv1_1)
147 BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_1 = 0x10000000L);
148 # endif // defined(SSL_OP_NO_TLSv1_1)
149 # if defined(SSL_OP_NO_TLSv1_2)
150 BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_2 = SSL_OP_NO_TLSv1_2);
151 # else // defined(SSL_OP_NO_TLSv1_2)
152 BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_2 = 0x08000000L);
153 # endif // defined(SSL_OP_NO_TLSv1_2)
154 # if defined(SSL_OP_NO_TLSv1_3)
155 BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_3 = SSL_OP_NO_TLSv1_3);
156 # else // defined(SSL_OP_NO_TLSv1_3)
157 BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_3 = 0x20000000L);
158 # endif // defined(SSL_OP_NO_TLSv1_3)
159 # if defined(SSL_OP_NO_COMPRESSION)
160 BOOST_ASIO_STATIC_CONSTANT(long, no_compression = SSL_OP_NO_COMPRESSION);
161 # else // defined(SSL_OP_NO_COMPRESSION)
162 BOOST_ASIO_STATIC_CONSTANT(long, no_compression = 0x20000L);
163 # endif // defined(SSL_OP_NO_COMPRESSION)
166 /// File format types.
176 #if !defined(GENERATING_DOCUMENTATION)
177 // The following types and constants are preserved for backward compatibility.
178 // New programs should use the equivalents of the same names that are defined
179 // in the boost::asio::ssl namespace.
180 typedef int verify_mode;
181 BOOST_ASIO_STATIC_CONSTANT(int, verify_none = SSL_VERIFY_NONE);
182 BOOST_ASIO_STATIC_CONSTANT(int, verify_peer = SSL_VERIFY_PEER);
183 BOOST_ASIO_STATIC_CONSTANT(int,
184 verify_fail_if_no_peer_cert = SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
185 BOOST_ASIO_STATIC_CONSTANT(int, verify_client_once = SSL_VERIFY_CLIENT_ONCE);
188 /// Purpose of PEM password.
189 enum password_purpose
191 /// The password is needed for reading/decryption.
194 /// The password is needed for writing/encryption.
199 /// Protected destructor to prevent deletion through this type.
209 #include <boost/asio/detail/pop_options.hpp>
211 #endif // BOOST_ASIO_SSL_CONTEXT_BASE_HPP