Apache HTTPD
Classes | Typedefs | Functions
tls_cert.h File Reference
#include "tls_util.h"

Go to the source code of this file.

Classes

struct  tls_cert_pem_t
 
struct  tls_cert_spec_t
 
struct  tls_cert_reg_t
 
struct  tls_cert_root_stores_t
 
struct  tls_cert_verifiers_t
 

Typedefs

typedef struct tls_cert_reg_t tls_cert_reg_t
 
typedef int tls_cert_reg_visitor(void *userdata, server_rec *s, const char *id, const char *cert_pem, const rustls_certified_key *certified_key)
 
typedef struct tls_cert_root_stores_t tls_cert_root_stores_t
 
typedef struct tls_cert_verifiers_t tls_cert_verifiers_t
 

Functions

apr_status_t tls_cert_load_pem (apr_pool_t *p, const tls_cert_spec_t *cert, tls_cert_pem_t **ppem)
 
apr_status_t tls_cert_to_pem (const char **ppem, apr_pool_t *p, const rustls_certificate *cert)
 
apr_status_t tls_cert_load_cert_key (apr_pool_t *p, const tls_cert_spec_t *spec, const char **pcert_pem, const rustls_certified_key **pckey)
 
tls_cert_reg_ttls_cert_reg_make (apr_pool_t *p)
 
apr_size_t tls_cert_reg_count (tls_cert_reg_t *reg)
 
apr_status_t tls_cert_reg_get_certified_key (tls_cert_reg_t *reg, server_rec *s, const tls_cert_spec_t *spec, const rustls_certified_key **pckey)
 
void tls_cert_reg_do (tls_cert_reg_visitor *visitor, void *userdata, tls_cert_reg_t *reg)
 
const chartls_cert_reg_get_id (tls_cert_reg_t *reg, const rustls_certified_key *certified_key)
 
apr_status_t tls_cert_load_root_store (apr_pool_t *p, const char *store_file, const rustls_root_cert_store **pstore)
 
tls_cert_root_stores_ttls_cert_root_stores_make (apr_pool_t *p)
 
void tls_cert_root_stores_clear (tls_cert_root_stores_t *stores)
 
apr_status_t tls_cert_root_stores_get (tls_cert_root_stores_t *stores, const char *store_file, const rustls_root_cert_store **pstore)
 
tls_cert_verifiers_ttls_cert_verifiers_make (apr_pool_t *p, tls_cert_root_stores_t *stores)
 
void tls_cert_verifiers_clear (tls_cert_verifiers_t *verifiers)
 
apr_status_t tls_cert_client_verifiers_get (tls_cert_verifiers_t *verifiers, const char *store_file, const rustls_client_cert_verifier **pverifier)
 
apr_status_t tls_cert_client_verifiers_get_optional (tls_cert_verifiers_t *verifiers, const char *store_file, const rustls_client_cert_verifier **pverifier)
 

Typedef Documentation

◆ tls_cert_reg_t

A registry of rustls_certified_key* by identifier.

Definition at line 62 of file tls_cert.h.

◆ tls_cert_reg_visitor

typedef int tls_cert_reg_visitor(void *userdata, server_rec *s, const char *id, const char *cert_pem, const rustls_certified_key *certified_key)

Visit all certified keys in the registry. The callback may return 0 to abort the iteration.

Parameters
userdatasupplied by the visit invocation
sthe server_rec the certified was load into first
idinternal identifier of the certified key
cert_pemthe PEM data of the certificate and its chain
certified_keythe key instance itself

Definition at line 102 of file tls_cert.h.

◆ tls_cert_root_stores_t

Definition at line 133 of file tls_cert.h.

◆ tls_cert_verifiers_t

Definition at line 162 of file tls_cert.h.

Function Documentation

◆ tls_cert_client_verifiers_get()

apr_status_t tls_cert_client_verifiers_get ( tls_cert_verifiers_t verifiers,
const char store_file,
const rustls_client_cert_verifier **  pverifier 
)

Get the mandatory client certificate verifier for the root certificate store in store_file. Will create the verifier if not already known.

Parameters
verifiersthe registry of certificate verifiers
store_filethe (server relative) path of the PEM file with certificates
pverifiersthe verifier on success

Definition at line 569 of file tls_cert.c.

◆ tls_cert_client_verifiers_get_optional()

apr_status_t tls_cert_client_verifiers_get_optional ( tls_cert_verifiers_t verifiers,
const char store_file,
const rustls_client_cert_verifier **  pverifier 
)

Get the optional client certificate verifier for the root certificate store in store_file. Will create the verifier if not already known.

Parameters
verifiersthe registry of certificate verifiers
store_filethe (server relative) path of the PEM file with certificates
pverifiersthe verifier on success

Definition at line 577 of file tls_cert.c.

◆ tls_cert_load_cert_key()

apr_status_t tls_cert_load_cert_key ( apr_pool_t p,
const tls_cert_spec_t spec,
const char **  pcert_pem,
const rustls_certified_key **  pckey 
)

Load a rustls certified key from a certificate specification. The returned rustls_certified_key is owned by the caller.

Parameters
pthe memory pool to use
specthe specification for the certificate (file or PEM data)
cert_pemreturn the PEM data used for loading the certificates, optional
pckeythe loaded certified key on return

Definition at line 177 of file tls_cert.c.

◆ tls_cert_load_pem()

apr_status_t tls_cert_load_pem ( apr_pool_t p,
const tls_cert_spec_t cert,
tls_cert_pem_t **  ppem 
)

Load the PEM data for a certificate file and key file as given in cert.

Definition at line 35 of file tls_cert.c.

◆ tls_cert_load_root_store()

apr_status_t tls_cert_load_root_store ( apr_pool_t p,
const char store_file,
const rustls_root_cert_store **  pstore 
)

Load all root certificates from a PEM file into a rustls_root_cert_store.

Parameters
pthe memory pool to use
store_filethe (server relative) path of the PEM file
pstorethe loaded root store on success

Definition at line 333 of file tls_cert.c.

◆ tls_cert_reg_count()

apr_size_t tls_cert_reg_count ( tls_cert_reg_t reg)

Return the number of certified keys in the registry.

Definition at line 254 of file tls_cert.c.

◆ tls_cert_reg_do()

void tls_cert_reg_do ( tls_cert_reg_visitor visitor,
void *  userdata,
tls_cert_reg_t reg 
)

Visit all certified_key entries in the registry.

Parameters
visitorcallback invoked on each entry until it returns 0.
userdatapassed to callback
regthe registry to iterate over

Definition at line 316 of file tls_cert.c.

◆ tls_cert_reg_get_certified_key()

apr_status_t tls_cert_reg_get_certified_key ( tls_cert_reg_t reg,
server_rec s,
const tls_cert_spec_t spec,
const rustls_certified_key **  pckey 
)

Get a the rustls_certified_key identified by spec from the registry. This will load the key the first time it is requested. The returned rustls_certified_key is owned by the registry.

Parameters
regthe certified key registry
sthe server_rec this is loaded into, useful for error logging
specthe specification of the certified key
pckeythe certified key instance on return

Definition at line 266 of file tls_cert.c.

◆ tls_cert_reg_get_id()

const char * tls_cert_reg_get_id ( tls_cert_reg_t reg,
const rustls_certified_key certified_key 
)

Get the identity assigned to a loaded, certified key. Returns NULL, if the key is not part of the registry. The returned bytes are owned by the registry entry.

Parameters
regthe registry to look in.
certified_keythe key to get the identifier for

Definition at line 325 of file tls_cert.c.

◆ tls_cert_reg_make()

tls_cert_reg_t * tls_cert_reg_make ( apr_pool_t p)

Create a new registry with lifetime based on the memory pool. The registry will take care of its memory and allocated keys when the pool is destroyed.

Definition at line 242 of file tls_cert.c.

◆ tls_cert_root_stores_clear()

void tls_cert_root_stores_clear ( tls_cert_root_stores_t stores)

Clear the root stores registry, freeing all stores.

Definition at line 420 of file tls_cert.c.

◆ tls_cert_root_stores_get()

apr_status_t tls_cert_root_stores_get ( tls_cert_root_stores_t stores,
const char store_file,
const rustls_root_cert_store **  pstore 
)

Load all root certificates from a PEM file into a rustls_root_cert_store.

Parameters
pthe memory pool to use
store_filethe (server relative) path of the PEM file
pstorethe loaded root store on success

Definition at line 428 of file tls_cert.c.

◆ tls_cert_root_stores_make()

tls_cert_root_stores_t * tls_cert_root_stores_make ( apr_pool_t p)

Create a new root stores registry with lifetime based on the memory pool. The registry will take care of its memory and allocated stores when the pool is destroyed.

Definition at line 409 of file tls_cert.c.

◆ tls_cert_to_pem()

apr_status_t tls_cert_to_pem ( const char **  ppem,
apr_pool_t p,
const rustls_certificate cert 
)

Definition at line 121 of file tls_cert.c.

◆ tls_cert_verifiers_clear()

void tls_cert_verifiers_clear ( tls_cert_verifiers_t verifiers)

Clear the verifiers registry, freeing all verifiers.

Definition at line 498 of file tls_cert.c.

◆ tls_cert_verifiers_make()

tls_cert_verifiers_t * tls_cert_verifiers_make ( apr_pool_t p,
tls_cert_root_stores_t stores 
)

Create a new registry for certificate verifiers with lifetime based on the memory pool. The registry will take care of its memory and allocated verifiers when the pool is destroyed.

Parameters
pthe memory pool to use
storesthe store registry for lookups

Definition at line 485 of file tls_cert.c.