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