]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // ssl/context_base.hpp | |
3 | // ~~~~~~~~~~~~~~~~~~~~ | |
4 | // | |
11fdf7f2 | 5 | // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
7c673cae FG |
6 | // |
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) | |
9 | // | |
10 | ||
11 | #ifndef BOOST_ASIO_SSL_CONTEXT_BASE_HPP | |
12 | #define BOOST_ASIO_SSL_CONTEXT_BASE_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
19 | #include <boost/asio/ssl/detail/openssl_types.hpp> | |
20 | ||
21 | #include <boost/asio/detail/push_options.hpp> | |
22 | ||
23 | namespace boost { | |
24 | namespace asio { | |
25 | namespace ssl { | |
26 | ||
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. | |
29 | class context_base | |
30 | { | |
31 | public: | |
32 | /// Different methods supported by a context. | |
33 | enum method | |
34 | { | |
35 | /// Generic SSL version 2. | |
36 | sslv2, | |
37 | ||
38 | /// SSL version 2 client. | |
39 | sslv2_client, | |
40 | ||
41 | /// SSL version 2 server. | |
42 | sslv2_server, | |
43 | ||
44 | /// Generic SSL version 3. | |
45 | sslv3, | |
46 | ||
47 | /// SSL version 3 client. | |
48 | sslv3_client, | |
49 | ||
50 | /// SSL version 3 server. | |
51 | sslv3_server, | |
52 | ||
53 | /// Generic TLS version 1. | |
54 | tlsv1, | |
55 | ||
56 | /// TLS version 1 client. | |
57 | tlsv1_client, | |
58 | ||
59 | /// TLS version 1 server. | |
60 | tlsv1_server, | |
61 | ||
62 | /// Generic SSL/TLS. | |
63 | sslv23, | |
64 | ||
65 | /// SSL/TLS client. | |
66 | sslv23_client, | |
67 | ||
68 | /// SSL/TLS server. | |
69 | sslv23_server, | |
70 | ||
71 | /// Generic TLS version 1.1. | |
72 | tlsv11, | |
73 | ||
74 | /// TLS version 1.1 client. | |
75 | tlsv11_client, | |
76 | ||
77 | /// TLS version 1.1 server. | |
78 | tlsv11_server, | |
79 | ||
80 | /// Generic TLS version 1.2. | |
81 | tlsv12, | |
82 | ||
83 | /// TLS version 1.2 client. | |
84 | tlsv12_client, | |
85 | ||
86 | /// TLS version 1.2 server. | |
b32b8144 FG |
87 | tlsv12_server, |
88 | ||
89 | /// Generic TLS. | |
90 | tls, | |
91 | ||
92 | /// TLS client. | |
93 | tls_client, | |
94 | ||
95 | /// TLS server. | |
96 | tls_server | |
7c673cae FG |
97 | }; |
98 | ||
99 | /// Bitmask type for SSL options. | |
100 | typedef long options; | |
101 | ||
102 | #if defined(GENERATING_DOCUMENTATION) | |
103 | /// Implement various bug workarounds. | |
104 | static const long default_workarounds = implementation_defined; | |
105 | ||
106 | /// Always create a new key when using tmp_dh parameters. | |
107 | static const long single_dh_use = implementation_defined; | |
108 | ||
109 | /// Disable SSL v2. | |
110 | static const long no_sslv2 = implementation_defined; | |
111 | ||
112 | /// Disable SSL v3. | |
113 | static const long no_sslv3 = implementation_defined; | |
114 | ||
115 | /// Disable TLS v1. | |
116 | static const long no_tlsv1 = implementation_defined; | |
117 | ||
118 | /// Disable TLS v1.1. | |
119 | static const long no_tlsv1_1 = implementation_defined; | |
120 | ||
121 | /// Disable TLS v1.2. | |
122 | static const long no_tlsv1_2 = implementation_defined; | |
123 | ||
124 | /// Disable compression. Compression is disabled by default. | |
125 | static const long no_compression = implementation_defined; | |
126 | #else | |
127 | BOOST_ASIO_STATIC_CONSTANT(long, default_workarounds = SSL_OP_ALL); | |
128 | BOOST_ASIO_STATIC_CONSTANT(long, single_dh_use = SSL_OP_SINGLE_DH_USE); | |
129 | BOOST_ASIO_STATIC_CONSTANT(long, no_sslv2 = SSL_OP_NO_SSLv2); | |
130 | BOOST_ASIO_STATIC_CONSTANT(long, no_sslv3 = SSL_OP_NO_SSLv3); | |
131 | BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1 = SSL_OP_NO_TLSv1); | |
132 | # if defined(SSL_OP_NO_TLSv1_1) | |
133 | BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_1 = SSL_OP_NO_TLSv1_1); | |
134 | # else // defined(SSL_OP_NO_TLSv1_1) | |
135 | BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_1 = 0x10000000L); | |
136 | # endif // defined(SSL_OP_NO_TLSv1_1) | |
137 | # if defined(SSL_OP_NO_TLSv1_2) | |
138 | BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_2 = SSL_OP_NO_TLSv1_2); | |
139 | # else // defined(SSL_OP_NO_TLSv1_2) | |
140 | BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_2 = 0x08000000L); | |
141 | # endif // defined(SSL_OP_NO_TLSv1_2) | |
142 | # if defined(SSL_OP_NO_COMPRESSION) | |
143 | BOOST_ASIO_STATIC_CONSTANT(long, no_compression = SSL_OP_NO_COMPRESSION); | |
144 | # else // defined(SSL_OP_NO_COMPRESSION) | |
145 | BOOST_ASIO_STATIC_CONSTANT(long, no_compression = 0x20000L); | |
146 | # endif // defined(SSL_OP_NO_COMPRESSION) | |
147 | #endif | |
148 | ||
149 | /// File format types. | |
150 | enum file_format | |
151 | { | |
152 | /// ASN.1 file. | |
153 | asn1, | |
154 | ||
155 | /// PEM file. | |
156 | pem | |
157 | }; | |
158 | ||
159 | #if !defined(GENERATING_DOCUMENTATION) | |
160 | // The following types and constants are preserved for backward compatibility. | |
161 | // New programs should use the equivalents of the same names that are defined | |
162 | // in the boost::asio::ssl namespace. | |
163 | typedef int verify_mode; | |
164 | BOOST_ASIO_STATIC_CONSTANT(int, verify_none = SSL_VERIFY_NONE); | |
165 | BOOST_ASIO_STATIC_CONSTANT(int, verify_peer = SSL_VERIFY_PEER); | |
166 | BOOST_ASIO_STATIC_CONSTANT(int, | |
167 | verify_fail_if_no_peer_cert = SSL_VERIFY_FAIL_IF_NO_PEER_CERT); | |
168 | BOOST_ASIO_STATIC_CONSTANT(int, verify_client_once = SSL_VERIFY_CLIENT_ONCE); | |
169 | #endif | |
170 | ||
171 | /// Purpose of PEM password. | |
172 | enum password_purpose | |
173 | { | |
174 | /// The password is needed for reading/decryption. | |
175 | for_reading, | |
176 | ||
177 | /// The password is needed for writing/encryption. | |
178 | for_writing | |
179 | }; | |
180 | ||
181 | protected: | |
182 | /// Protected destructor to prevent deletion through this type. | |
183 | ~context_base() | |
184 | { | |
185 | } | |
186 | }; | |
187 | ||
188 | } // namespace ssl | |
189 | } // namespace asio | |
190 | } // namespace boost | |
191 | ||
192 | #include <boost/asio/detail/pop_options.hpp> | |
193 | ||
194 | #endif // BOOST_ASIO_SSL_CONTEXT_BASE_HPP |