HTTP-2-lib
Static Public Member Functions
h2_config Class Reference

#include <h2_config.hpp>

Static Public Member Functions

static int nextProtocolCallback (SSL *s, const unsigned char **out, unsigned int *outlen, void *arg)
 
static int selectProtocol (unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen)
 
static int alpnSelectProtocolCallback (SSL *ssl, const unsigned char **out, unsigned char *outlength, const unsigned char *in, unsigned int inlen, void *arg)
 
static void configureAlpn (SSL_CTX *ctx)
 
static void createApplicationContext (struct ApplicationContext *appCtx, SSL_CTX *sslCtx, struct event_base *eventBase_, std::unordered_map< std::string, std::string > routes)
 
static SSL_CTX * createSslContext ()
 
static void configureContext (SSL_CTX *ctx, const char *certKeyFile, const char *certFile)
 
static void initOpenssl ()
 Initiates openSSL. More...
 
static void cleanupOpenssl ()
 Cleaning up openssl environment. More...
 

Member Function Documentation

◆ alpnSelectProtocolCallback()

int h2_config::alpnSelectProtocolCallback ( SSL *  ssl,
const unsigned char **  out,
unsigned char *  outlength,
const unsigned char *  in,
unsigned int  inlen,
void *  arg 
)
static

Callback function used for the negotiation of HTTP/2 over TLS in ALPN.

Parameters
ssl- SSL object (unused parameter).
out- string for chosen protocol
outlength- length of name of chosen protocol given in 'out'.
in- protocols supported by the client.
inlen- length of 'in'.
arg
Returns
0 on success and non-zero on failure.

◆ cleanupOpenssl()

void h2_config::cleanupOpenssl ( )
static

Cleaning up openssl environment.

◆ configureAlpn()

void h2_config::configureAlpn ( SSL_CTX *  ctx)
static

Configures the referenced SSL_CTX object to use the Aplication Protocol Layer Negotiation extension, with 'nextProtocolCallback' and 'alpnSelectProtocolCallback'.

Parameters
ctx- reference to the SSL_CTX object to configure ALPN extension on.

◆ configureContext()

void h2_config::configureContext ( SSL_CTX *  ctx,
const char *  certKeyFile,
const char *  certFile 
)
static

Configures the SSL_CTX object to use given certificate and private key, and calls to configure ALPN extension.

Parameters
ctx- reference to the SSL_CTX object to configure.
certKeyFile- path to Certificate Key File to be used for TLS.
certFile- path to Certificate File to be used for TLS.

◆ createApplicationContext()

void h2_config::createApplicationContext ( struct ApplicationContext appCtx,
SSL_CTX *  sslCtx,
struct event_base *  eventBase_,
std::unordered_map< std::string, std::string >  routes 
)
static

Initializes the application wide application_ctx object on the refernece given.

Parameters
appCtx- reference to appCtx object to initialize.
sslCtx- SSL_CTX object to use.
eventBase_- event_base object to use.

◆ createSslContext()

SSL_CTX * h2_config::createSslContext ( )
static

Creates a new SSL_CTX object and sets the connection method to be used, which is a general SSL/TLS server connection method.

Returns
SSL_CTX - The newly created SSL_CTX object with the connection method set.

◆ initOpenssl()

void h2_config::initOpenssl ( )
static

Initiates openSSL.

◆ nextProtocolCallback()

int h2_config::nextProtocolCallback ( SSL *  s,
const unsigned char **  out,
unsigned int *  outlen,
void *  arg 
)
static

Callback function used when the TLS server needs a list of supported protocols for Next Protocol Negotiation.

Parameters
s- SSL object (unused)
out- pointer to list of supported protocols in protocol-list format.
outlen- length of 'out'.
arg- user supplied context (unused).
Returns
int - SSL_TLSEXT_ERR_OK

◆ selectProtocol()

int h2_config::selectProtocol ( unsigned char **  out,
unsigned char *  outlen,
const unsigned char *  in,
unsigned int  inlen 
)
static

Selects 'h2' meaning 'HTTP/2 over TLS'

Parameters
out- name of protocol chosen by the server.
outlen- length of name of protocol given in 'out'.
in- string of protocols supported by the client, prefixed by the length of the following protocol.
inlen- total length of the protocols-string 'in'.
Returns
1 if successful.

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