Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::security::SSLContext Class Referencefinal

SSL context. More...

#include <SSLContext.h>

Inheritance diagram for sese::security::SSLContext:

Public Types

using Ptr = std::shared_ptr<SSLContext>
 
using Socket = sese::net::Socket
 

Public Member Functions

 SSLContext (const void *method) noexcept
 
 ~SSLContext () noexcept
 
void * getContext () const noexcept
 
bool importCertFile (const char *file) const noexcept
 Load certificate from file.
 
bool importPrivateKeyFile (const char *file) const noexcept
 Load private key from file.
 
bool authPrivateKey () const noexcept
 Verify certificate and private key.
 
Socket::Ptr newSocketPtr (Socket::Family family, int32_t flags)
 Create a TCP socket from the current context.
 
void * release () noexcept
 Release ownership of the current object.
 
std::unique_ptr< SSLContextcopy () const noexcept
 Deep copy the current context, including certificates and private keys (must exist), with independent lifecycle.
 

Static Public Member Functions

static ErrorCode getErrorCode () noexcept
 

Private Member Functions

 SSLContext ()=default
 

Private Attributes

void * context = nullptr
 

Detailed Description

SSL context.

Member Typedef Documentation

◆ Ptr

using sese::security::SSLContext::Ptr = std::shared_ptr<SSLContext>

◆ Socket

Constructor & Destructor Documentation

◆ SSLContext() [1/2]

SSLContext::SSLContext ( const void * method)
explicitnoexcept

◆ ~SSLContext()

SSLContext::~SSLContext ( )
noexcept

References context.

◆ SSLContext() [2/2]

sese::security::SSLContext::SSLContext ( )
privatedefault

Member Function Documentation

◆ authPrivateKey()

bool SSLContext::authPrivateKey ( ) const
noexcept

Verify certificate and private key.

Returns
Verification result

References context.

◆ copy()

std::unique_ptr< SSLContext > SSLContext::copy ( ) const
noexcept

Deep copy the current context, including certificates and private keys (must exist), with independent lifecycle.

Returns
SSL context

References context, and MAKE_UNIQUE_PRIVATE.

◆ getContext()

void * SSLContext::getContext ( ) const
nodiscardnoexcept

References context.

◆ getErrorCode()

sese::ErrorCode SSLContext::getErrorCode ( )
staticnoexcept

◆ importCertFile()

bool SSLContext::importCertFile ( const char * file) const
noexcept

Load certificate from file.

Parameters
filePath to the certificate file
Returns
Loading result

◆ importPrivateKeyFile()

bool SSLContext::importPrivateKeyFile ( const char * file) const
noexcept

Load private key from file.

Note
This function implements via SSL_CTX_use_PrivateKey_file, it will also verify the certificate
Parameters
filePath to the private key file
Returns
Loading result

◆ newSocketPtr()

sese::net::Socket::Ptr SSLContext::newSocketPtr ( Socket::Family family,
int32_t flags )

Create a TCP socket from the current context.

Parameters
familyProtocol family
flagsFlags
Returns
The created socket

References context.

◆ release()

void * SSLContext::release ( )
noexcept

Release ownership of the current object.

Warning
Note: This function is used to address asio::ssl::context not following the who allocates who releases principle. After calling this function, the object will lose control of SSL_CTX. Unless you are very sure of what you are doing, do not use this function. If you only need to obtain SSL_CTX without changing its lifecycle, please use getContext.
Returns
Underlying SSL_CTX pointer

References context.

Member Data Documentation

◆ context

void* sese::security::SSLContext::context = nullptr
private

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