Chris@16: // Chris@16: // ssl/context_base.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_SSL_CONTEXT_BASE_HPP Chris@16: #define BOOST_ASIO_SSL_CONTEXT_BASE_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace ssl { Chris@16: Chris@16: /// The context_base class is used as a base for the basic_context class Chris@16: /// template so that we have a common place to define various enums. Chris@16: class context_base Chris@16: { Chris@16: public: Chris@16: /// Different methods supported by a context. Chris@16: enum method Chris@16: { Chris@16: /// Generic SSL version 2. Chris@16: sslv2, Chris@16: Chris@16: /// SSL version 2 client. Chris@16: sslv2_client, Chris@16: Chris@16: /// SSL version 2 server. Chris@16: sslv2_server, Chris@16: Chris@16: /// Generic SSL version 3. Chris@16: sslv3, Chris@16: Chris@16: /// SSL version 3 client. Chris@16: sslv3_client, Chris@16: Chris@16: /// SSL version 3 server. Chris@16: sslv3_server, Chris@16: Chris@16: /// Generic TLS version 1. Chris@16: tlsv1, Chris@16: Chris@16: /// TLS version 1 client. Chris@16: tlsv1_client, Chris@16: Chris@16: /// TLS version 1 server. Chris@16: tlsv1_server, Chris@16: Chris@16: /// Generic SSL/TLS. Chris@16: sslv23, Chris@16: Chris@16: /// SSL/TLS client. Chris@16: sslv23_client, Chris@16: Chris@16: /// SSL/TLS server. Chris@16: sslv23_server, Chris@16: Chris@16: /// Generic TLS version 1.1. Chris@16: tlsv11, Chris@16: Chris@16: /// TLS version 1.1 client. Chris@16: tlsv11_client, Chris@16: Chris@16: /// TLS version 1.1 server. Chris@16: tlsv11_server, Chris@16: Chris@16: /// Generic TLS version 1.2. Chris@16: tlsv12, Chris@16: Chris@16: /// TLS version 1.2 client. Chris@16: tlsv12_client, Chris@16: Chris@16: /// TLS version 1.2 server. Chris@16: tlsv12_server Chris@16: }; Chris@16: Chris@16: /// Bitmask type for SSL options. Chris@16: typedef long options; Chris@16: Chris@16: #if defined(GENERATING_DOCUMENTATION) Chris@16: /// Implement various bug workarounds. Chris@16: static const long default_workarounds = implementation_defined; Chris@16: Chris@16: /// Always create a new key when using tmp_dh parameters. Chris@16: static const long single_dh_use = implementation_defined; Chris@16: Chris@16: /// Disable SSL v2. Chris@16: static const long no_sslv2 = implementation_defined; Chris@16: Chris@16: /// Disable SSL v3. Chris@16: static const long no_sslv3 = implementation_defined; Chris@16: Chris@16: /// Disable TLS v1. Chris@16: static const long no_tlsv1 = implementation_defined; Chris@16: Chris@101: /// Disable TLS v1.1. Chris@101: static const long no_tlsv1_1 = implementation_defined; Chris@101: Chris@101: /// Disable TLS v1.2. Chris@101: static const long no_tlsv1_2 = implementation_defined; Chris@101: Chris@16: /// Disable compression. Compression is disabled by default. Chris@16: static const long no_compression = implementation_defined; Chris@16: #else Chris@16: BOOST_ASIO_STATIC_CONSTANT(long, default_workarounds = SSL_OP_ALL); Chris@16: BOOST_ASIO_STATIC_CONSTANT(long, single_dh_use = SSL_OP_SINGLE_DH_USE); Chris@16: BOOST_ASIO_STATIC_CONSTANT(long, no_sslv2 = SSL_OP_NO_SSLv2); Chris@16: BOOST_ASIO_STATIC_CONSTANT(long, no_sslv3 = SSL_OP_NO_SSLv3); Chris@16: BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1 = SSL_OP_NO_TLSv1); Chris@101: # if defined(SSL_OP_NO_TLSv1_1) Chris@101: BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_1 = SSL_OP_NO_TLSv1_1); Chris@101: # else // defined(SSL_OP_NO_TLSv1_1) Chris@101: BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_1 = 0x10000000L); Chris@101: # endif // defined(SSL_OP_NO_TLSv1_1) Chris@101: # if defined(SSL_OP_NO_TLSv1_2) Chris@101: BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_2 = SSL_OP_NO_TLSv1_2); Chris@101: # else // defined(SSL_OP_NO_TLSv1_2) Chris@101: BOOST_ASIO_STATIC_CONSTANT(long, no_tlsv1_2 = 0x08000000L); Chris@101: # endif // defined(SSL_OP_NO_TLSv1_2) Chris@16: # if defined(SSL_OP_NO_COMPRESSION) Chris@16: BOOST_ASIO_STATIC_CONSTANT(long, no_compression = SSL_OP_NO_COMPRESSION); Chris@16: # else // defined(SSL_OP_NO_COMPRESSION) Chris@16: BOOST_ASIO_STATIC_CONSTANT(long, no_compression = 0x20000L); Chris@16: # endif // defined(SSL_OP_NO_COMPRESSION) Chris@16: #endif Chris@16: Chris@16: /// File format types. Chris@16: enum file_format Chris@16: { Chris@16: /// ASN.1 file. Chris@16: asn1, Chris@16: Chris@16: /// PEM file. Chris@16: pem Chris@16: }; Chris@16: Chris@16: #if !defined(GENERATING_DOCUMENTATION) Chris@16: // The following types and constants are preserved for backward compatibility. Chris@16: // New programs should use the equivalents of the same names that are defined Chris@16: // in the boost::asio::ssl namespace. Chris@16: typedef int verify_mode; Chris@16: BOOST_ASIO_STATIC_CONSTANT(int, verify_none = SSL_VERIFY_NONE); Chris@16: BOOST_ASIO_STATIC_CONSTANT(int, verify_peer = SSL_VERIFY_PEER); Chris@16: BOOST_ASIO_STATIC_CONSTANT(int, Chris@16: verify_fail_if_no_peer_cert = SSL_VERIFY_FAIL_IF_NO_PEER_CERT); Chris@16: BOOST_ASIO_STATIC_CONSTANT(int, verify_client_once = SSL_VERIFY_CLIENT_ONCE); Chris@16: #endif Chris@16: Chris@16: /// Purpose of PEM password. Chris@16: enum password_purpose Chris@16: { Chris@16: /// The password is needed for reading/decryption. Chris@16: for_reading, Chris@16: Chris@16: /// The password is needed for writing/encryption. Chris@16: for_writing Chris@16: }; Chris@16: Chris@16: protected: Chris@16: /// Protected destructor to prevent deletion through this type. Chris@16: ~context_base() Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace ssl Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_ASIO_SSL_CONTEXT_BASE_HPP