Kea  2.1.7-git
isc::asiolink::TlsContextBase Class Referenceabstract

TLS context base class. More...

#include <common_tls.h>

+ Inheritance diagram for isc::asiolink::TlsContextBase:

Public Member Functions

 TlsContextBase (TlsRole role)
 Create a fresh context. More...
 
virtual ~TlsContextBase ()
 Destructor. More...
 
virtual bool getCertRequired () const =0
 Get the peer certificate requirement mode. More...
 
TlsRole getRole () const
 Returns the role. More...
 

Static Public Member Functions

static void configure (TlsContextPtr &context, TlsRole role, const std::string &ca_file, const std::string &cert_file, const std::string &key_file, bool cert_required=true)
 Configure. More...
 

Public Attributes

TlsRole role_
 The role i.e. client or server. More...
 

Protected Member Functions

virtual void loadCaFile (const std::string &ca_file)=0
 Load the trust anchor aka certification authority. More...
 
virtual void loadCaPath (const std::string &ca_path)=0
 Load the trust anchor aka certification authority. More...
 
virtual void loadCertFile (const std::string &cert_file)=0
 Load the certificate file. More...
 
virtual void loadKeyFile (const std::string &key_file)=0
 Load the private key from a file. More...
 
virtual void setCertRequired (bool cert_required)=0
 Set the peer certificate requirement mode. More...
 

Detailed Description

TLS context base class.

Definition at line 40 of file common_tls.h.

Constructor & Destructor Documentation

◆ ~TlsContextBase()

virtual isc::asiolink::TlsContextBase::~TlsContextBase ( )
inlinevirtual

Destructor.

Definition at line 43 of file common_tls.h.

◆ TlsContextBase()

isc::asiolink::TlsContextBase::TlsContextBase ( TlsRole  role)
inlineexplicit

Create a fresh context.

Parameters
roleThe TLS role client or server.

Definition at line 48 of file common_tls.h.

Member Function Documentation

◆ configure()

void isc::asiolink::TlsContextBase::configure ( TlsContextPtr context,
TlsRole  role,
const std::string &  ca_file,
const std::string &  cert_file,
const std::string &  key_file,
bool  cert_required = true 
)
static

Configure.

Note
No need for a role set method.
Parameters
contextThe TLS context to configure.
roleThe TLS role client or server.
ca_fileThe certificate file or directory name.
cert_fileThe certificate file name.
key_fileThe private key file name.
cert_requiredTrue if peer certificates are required, false if they are optional. This is a server specific parameter.
Exceptions
isc::BadValueon error.

Definition at line 22 of file common_tls.cc.

References isc_throw, isc::util::file::isDir(), and isc::Exception::what().

Referenced by getRole().

+ Here is the call graph for this function:

◆ getCertRequired()

virtual bool isc::asiolink::TlsContextBase::getCertRequired ( ) const
pure virtual

Get the peer certificate requirement mode.

Returns
True if peer certificates are required, false if they are optional.

Referenced by getRole().

◆ getRole()

TlsRole isc::asiolink::TlsContextBase::getRole ( ) const
inline

Returns the role.

Definition at line 51 of file common_tls.h.

References configure(), getCertRequired(), loadCaFile(), loadCaPath(), loadCertFile(), loadKeyFile(), role_, and setCertRequired().

+ Here is the call graph for this function:

◆ loadCaFile()

virtual void isc::asiolink::TlsContextBase::loadCaFile ( const std::string &  ca_file)
protectedpure virtual

Load the trust anchor aka certification authority.

Parameters
ca_fileThe certificate file name.
Exceptions
isc::cryptolink::LibraryErroron various errors as file not found, bad format, etc.

Referenced by getRole().

◆ loadCaPath()

virtual void isc::asiolink::TlsContextBase::loadCaPath ( const std::string &  ca_path)
protectedpure virtual

Load the trust anchor aka certification authority.

Parameters
ca_pathThe certificate directory name.
Exceptions
isc::cryptolink::LibraryErroron various errors as file not found, bad format, etc.

Referenced by getRole().

◆ loadCertFile()

virtual void isc::asiolink::TlsContextBase::loadCertFile ( const std::string &  cert_file)
protectedpure virtual

Load the certificate file.

Parameters
cert_fileThe certificate file name.
Exceptions
isc::cryptolink::LibraryErroron various errors as file not found, bad format, etc.

Referenced by getRole().

◆ loadKeyFile()

virtual void isc::asiolink::TlsContextBase::loadKeyFile ( const std::string &  key_file)
protectedpure virtual

Load the private key from a file.

Parameters
key_fileThe private key file name.
Exceptions
isc::cryptolink::LibraryErroron various errors as file not found, bad format, etc.

Referenced by getRole().

◆ setCertRequired()

virtual void isc::asiolink::TlsContextBase::setCertRequired ( bool  cert_required)
protectedpure virtual

Set the peer certificate requirement mode.

Parameters
cert_requiredTrue if peer certificates are required, false if they are optional.
Exceptions
isc::BadValuewhen cert_required is set to false for a client.

Referenced by getRole().

Member Data Documentation

◆ role_

TlsRole isc::asiolink::TlsContextBase::role_

The role i.e. client or server.

Definition at line 118 of file common_tls.h.

Referenced by getRole(), and isc::asiolink::TlsStreamBase< Callback, TlsStreamImpl >::getRole().


The documentation for this class was generated from the following files: