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

Owns an OpenSSL SSL_CTX and optional log callback. 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 TLS client context (no certificate required).
 
static TSslContext Server (const char *certfile, const char *keyfile, const std::function< void(const char *)> &logFunc={})
 Creates a TLS server context from PEM files on disk.
 
static TSslContext ServerFromMem (const void *certfile, const void *keyfile, const std::function< void(const char *)> &logFunc={})
 Creates a TLS server context from PEM data already in memory.
 

Public Attributes

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

Detailed Description

Owns an OpenSSL SSL_CTX and optional log callback.

Move-only. Create via the static factory methods, then pass a reference to TSslSocket. The context must outlive every TSslSocket that uses it.

// TLS client
// TLS server (PEM files)
TSslContext ctx = TSslContext::Server("server.crt", "server.key");
// TLS server (in-memory PEM)
TSslContext ctx = TSslContext::ServerFromMem(certPem, keyPem);
Owns an OpenSSL SSL_CTX and optional log callback.
Definition ssl.hpp:39
static TSslContext ServerFromMem(const void *certfile, const void *keyfile, const std::function< void(const char *)> &logFunc={})
Creates a TLS server context from PEM data already in memory.
Definition ssl.cpp:53
static TSslContext Client(const std::function< void(const char *)> &logFunc={})
Creates a TLS client context (no certificate required).
Definition ssl.cpp:24
static TSslContext Server(const char *certfile, const char *keyfile, const std::function< void(const char *)> &logFunc={})
Creates a TLS server context from PEM files on disk.
Definition ssl.cpp:32

Member Function Documentation

◆ Client()

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

Creates a TLS client context (no certificate required).

Parameters
logFuncOptional callback for SSL state-change messages.

◆ Server()

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

Creates a TLS server context from PEM files on disk.

Parameters
certfilePath to the PEM certificate file (or chain).
keyfilePath to the PEM private key file.
logFuncOptional callback for SSL state-change messages.

◆ ServerFromMem()

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

Creates a TLS server context from PEM data already in memory.

Both certfile and keyfile must point to null-terminated PEM strings.

Parameters
certfilePEM certificate (or chain) in memory.
keyfilePEM private key in memory.
logFuncOptional callback for SSL state-change messages.

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