wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
certreload.h File Reference

Load (or reload) a server's certificate chain and P-256 signing key from a cert.pem (fullchain, leaf first, RFC 7468 5) and key.pem (SEC1 or PKCS#8 EC private key, RFC 7468 4) pair on disk. More...

Go to the source code of this file.

Data Structures

struct  wired_certreload_store
 Caller-owned storage a load fills: the DER bytes of every chain certificate (concatenated), spans into that buffer (leaf first), and the decoded P-256 private scalar. More...

Macros

#define WIRED_CERTRELOAD_CHAIN_MAX   10
 At most this many CERTIFICATE blocks are read from a fullchain cert.pem (leaf + intermediates).

Functions

int wired_certreload_load (const char *cert_path, const char *key_path, wired_certreload_store *store, wired_srvboot_id *id)
 Read cert_path/key_path, decode the PEM chain and private key into store, and point id->chain/chain_count/cert_seed at store's fields.
void wired_certreload_load_or_selfsigned (const char *cert_path, const char *key_path, wired_certreload_store *store, wired_srvboot_id *id)
 If cert_path is set (non-NULL, non-empty), load the certificate/key pair via wired_certreload_load into store/id, replacing id's self-signed identity with the loaded one.

Detailed Description

Load (or reload) a server's certificate chain and P-256 signing key from a cert.pem (fullchain, leaf first, RFC 7468 5) and key.pem (SEC1 or PKCS#8 EC private key, RFC 7468 4) pair on disk.

Shared by the example app's startup path and by a running server's SIGHUP-triggered hot reload (app/http3/server/srvrun), so the parsing logic exists exactly once.

Macro Definition Documentation

◆ WIRED_CERTRELOAD_CHAIN_MAX

#define WIRED_CERTRELOAD_CHAIN_MAX   10

At most this many CERTIFICATE blocks are read from a fullchain cert.pem (leaf + intermediates).

Sized past quic-interop-runner's amplificationlimit case, which deliberately serves a 9-certificate chain to inflate the server's Handshake flight for its RFC 9000 8.1 anti-amplification check; matches TLS_CERT_CHAIN_MAX (sdrv/cert.h) so a chain this loader accepts is never rejected downstream at the TLS flight-build layer.

Function Documentation

◆ wired_certreload_load()

int wired_certreload_load ( const char * cert_path,
const char * key_path,
wired_certreload_store * store,
wired_srvboot_id * id )

Read cert_path/key_path, decode the PEM chain and private key into store, and point id->chain/chain_count/cert_seed at store's fields.

id's other fields (priv/pub/scid/random) are left untouched.

Parameters
cert_pathNUL-terminated path to a fullchain PEM (leaf first)
key_pathNUL-terminated path to a PEM P-256 private key
storecaller-owned storage; must outlive id's use
idupdated in place on success; left unmodified on failure
Returns
1 on success; 0 if either file cannot be read, the PEM/DER is malformed, or the chain has zero certificates.

◆ wired_certreload_load_or_selfsigned()

void wired_certreload_load_or_selfsigned ( const char * cert_path,
const char * key_path,
wired_certreload_store * store,
wired_srvboot_id * id )

If cert_path is set (non-NULL, non-empty), load the certificate/key pair via wired_certreload_load into store/id, replacing id's self-signed identity with the loaded one.

wired_die()s with a diagnostic if cert_path is set but the load fails (e.g. key_path missing or unreadable). A no-op when cert_path is unset — id keeps whatever identity the caller already set (typically a demo self-signed one).

Parameters
cert_pathNUL-terminated certificate PEM path, or 0/empty to skip
key_pathNUL-terminated private key PEM path
storedestination for the loaded chain/key material
idserver identity to update on success