Botan  1.11.15
src/lib/tls/tls_server.h
Go to the documentation of this file.
00001 /*
00002 * TLS Server
00003 * (C) 2004-2011 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_TLS_SERVER_H__
00009 #define BOTAN_TLS_SERVER_H__
00010 
00011 #include <botan/tls_channel.h>
00012 #include <botan/credentials_manager.h>
00013 #include <vector>
00014 
00015 namespace Botan {
00016 
00017 namespace TLS {
00018 
00019 /**
00020 * TLS Server
00021 */
00022 class BOTAN_DLL Server : public Channel
00023    {
00024    public:
00025       /**
00026       * Server initialization
00027       */
00028       Server(output_fn output,
00029              data_cb data_cb,
00030              alert_cb alert_cb,
00031              handshake_cb handshake_cb,
00032              Session_Manager& session_manager,
00033              Credentials_Manager& creds,
00034              const Policy& policy,
00035              RandomNumberGenerator& rng,
00036              const std::vector<std::string>& protocols = std::vector<std::string>(),
00037              bool is_datagram = false,
00038              size_t reserved_io_buffer_size = 16*1024
00039          );
00040 
00041       /**
00042       * Return the protocol notification set by the client (using the
00043       * NPN extension) for this connection, if any. This value is not
00044       * tied to the session and a later renegotiation of the same
00045       * session can choose a new protocol.
00046       */
00047       std::string next_protocol() const { return m_next_protocol; }
00048 
00049    private:
00050       std::vector<X509_Certificate>
00051          get_peer_cert_chain(const Handshake_State& state) const override;
00052 
00053       void initiate_handshake(Handshake_State& state,
00054                               bool force_full_renegotiation) override;
00055 
00056       void process_handshake_msg(const Handshake_State* active_state,
00057                                  Handshake_State& pending_state,
00058                                  Handshake_Type type,
00059                                  const std::vector<byte>& contents) override;
00060 
00061       Handshake_State* new_handshake_state(Handshake_IO* io) override;
00062 
00063       const Policy& m_policy;
00064       Credentials_Manager& m_creds;
00065 
00066       std::vector<std::string> m_possible_protocols;
00067       std::string m_next_protocol;
00068    };
00069 
00070 }
00071 
00072 }
00073 
00074 #endif