COROIO: NNet::TSslContext Struct Reference
COROIO
 
Loading...
Searching...
No Matches
NNet::TSslContext Struct Reference

Encapsulates an OpenSSL context (SSL_CTX) with optional logging. More...

#include <ssl.hpp>

Public Member Functions

 TSslContext (TSslContext &&other)
 

Static Public Member Functions

static TSslContext Client (const std::function< void(const char *)> &logFunc={})
 Creates a client SSL context.
 
static TSslContext Server (const char *certfile, const char *keyfile, const std::function< void(const char *)> &logFunc={})
 Creates a server SSL context using certificate and key files.
 
static TSslContext ServerFromMem (const void *certfile, const void *keyfile, const std::function< void(const char *)> &logFunc={})
 Creates a server SSL context from in-memory certificate and key data.
 

Public Attributes

SSL_CTX * Ctx
 The underlying OpenSSL context.
 
std::function< void(const char *)> LogFunc = {}
 Optional logging callback.
 

Detailed Description

Encapsulates an OpenSSL context (SSL_CTX) with optional logging.

TSslContext holds a pointer to an OpenSSL SSL_CTX, which is used to configure SSL/TLS parameters. It optionally accepts a logging function to report state changes or errors during SSL operations.

The context can be created for client or server mode:

  • Use Client() to create a client context.
  • Use Server() to create a server context using certificate and key files.
  • Use ServerFromMem() to create a server context from in-memory certificate and key data.

The context is movable but not copyable. Upon destruction, any associated resources are released.

Member Function Documentation

◆ Client()

static TSslContext NNet::TSslContext::Client ( const std::function< void(const char *)> & logFunc = {})
static

Creates a client SSL context.

Parameters
logFuncOptional logging function.
Returns
A TSslContext configured for client mode.

◆ Server()

static TSslContext NNet::TSslContext::Server ( const char * certfile,
const char * keyfile,
const std::function< void(const char *)> & logFunc = {} )
static

Creates a server SSL context using certificate and key files.

Parameters
certfilePath to the certificate file.
keyfilePath to the key file.
logFuncOptional logging function.
Returns
A TSslContext configured for server mode.

◆ ServerFromMem()

static TSslContext NNet::TSslContext::ServerFromMem ( const void * certfile,
const void * keyfile,
const std::function< void(const char *)> & logFunc = {} )
static

Creates a server SSL context from in-memory certificate and key data.

Parameters
certfilePointer to the certificate data in memory.
keyfilePointer to the key data in memory.
logFuncOptional logging function.
Returns
A TSslContext configured for server mode.

The documentation for this struct was generated from the following file: