Kea  1.9.9-git
botan_tls.h
Go to the documentation of this file.
1 // Copyright (C) 2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 // Do not include this header directly: use crypto_tls.h instead.
8 
9 #ifndef BOTAN_TLS_H
10 #define BOTAN_TLS_H
11 
13 
14 #if defined(WITH_BOTAN) && !defined(WITH_BOTAN_BOOST)
15 
16 #include <asiolink/asio_wrapper.h>
18 #include <asiolink/io_service.h>
19 #include <asiolink/common_tls.h>
20 
21 #include <exceptions/exceptions.h>
22 
23 namespace isc {
24 namespace asiolink {
25 
27 class TlsContext : public TlsContextBase {
28 public:
29 
31  virtual ~TlsContext() { }
32 
36  explicit TlsContext(TlsRole role);
37 
42  virtual bool getCertRequired() const;
43 
44 protected:
49  virtual void setCertRequired(bool cert_required);
50 
56  virtual void loadCaFile(const std::string& ca_file);
57 
63  virtual void loadCaPath(const std::string& ca_path);
64 
70  virtual void loadCertFile(const std::string& cert_file);
71 
77  virtual void loadKeyFile(const std::string& key_file);
78 
80  bool cert_required_;
81 
83  friend class TlsContextBase;
84 };
85 
87 typedef boost::asio::ip::tcp::socket TlsStreamImpl;
88 
96 template <typename Callback, typename TlsStreamImpl>
98 TlsStreamBase(IOService& service, TlsContextPtr context)
99  : TlsStreamImpl(service.get_io_service()), role_(context->getRole()) {
100 }
101 
105 template <typename Callback>
106 class TlsStream : public TlsStreamBase<Callback, TlsStreamImpl> {
107 public:
108 
110  typedef TlsStreamBase<Callback, TlsStreamImpl> Base;
111 
117  TlsStream(IOService& service, TlsContextPtr context)
118  : Base(service, context) {
119  }
120 
122  virtual ~TlsStream() { }
123 
125  virtual void handshake(Callback&) {
126  isc_throw(NotImplemented, "Botan TLS is not yet supported");
127  }
128 
130  virtual void shutdown(Callback&) {
131  isc_throw(NotImplemented, "Botan TLS is not yet supported");
132  }
133 
144  std::string getSubject() {
145  return ("");
146  }
147 
158  std::string getIssuer() {
159  return ("");
160  }
161 };
162 
163 } // namespace asiolink
164 } // namespace isc
165 
166 #endif // WITH_BOTAN && !WITH_BOTAN_BOOST
167 
168 #endif // BOTAN_TLS_H
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Common TLS API.
Defines the logger used by the top-level component of kea-dhcp-ddns.