NetSurf
Macros | Functions
ssl_certs.c File Reference

helpers for X509 certificate chains More...

#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <nsutils/base64.h>
#include "utils/errors.h"
#include "utils/log.h"
#include "utils/nsurl.h"
#include "netsurf/ssl_certs.h"
Include dependency graph for ssl_certs.c:

Go to the source code of this file.

Macros

#define MIN_CERT_LEN   64
 

Functions

nserror cert_chain_alloc (size_t depth, struct cert_chain **chain_out)
 create new certificate chain More...
 
nserror cert_chain_dup_into (const struct cert_chain *src, struct cert_chain *dst)
 duplicate a certificate chain into an existing chain More...
 
nserror cert_chain_dup (const struct cert_chain *src, struct cert_chain **dst_out)
 duplicate a certificate chain More...
 
static nserror process_query_section (const char *str, size_t len, struct cert_chain *chain)
 process a part of a query extracting the certificate of an error code More...
 
nserror cert_chain_from_query (struct nsurl *url, struct cert_chain **chain_out)
 create a certificate chain from a fetch query string More...
 
nserror cert_chain_to_query (struct cert_chain *chain, struct nsurl **url_out)
 create a fetch query string from a certificate chain More...
 
nserror cert_chain_free (struct cert_chain *chain)
 free a certificate chain More...
 
size_t cert_chain_size (const struct cert_chain *chain)
 total number of data bytes in a chain More...
 

Detailed Description

helpers for X509 certificate chains

Definition in file ssl_certs.c.

Macro Definition Documentation

◆ MIN_CERT_LEN

#define MIN_CERT_LEN   64

Definition at line 133 of file ssl_certs.c.

Function Documentation

◆ cert_chain_alloc()

nserror cert_chain_alloc ( size_t  depth,
struct cert_chain **  chain_out 
)

create new certificate chain

Parameters
dpththe depth to set in the new chain.
chain_outA pointer to recive the new chain.
Returns
NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion

Definition at line 41 of file ssl_certs.c.

References cert_chain::depth, NSERROR_NOMEM, and NSERROR_OK.

Referenced by cert_chain_dup(), cert_chain_from_query(), curl_fetch_ssl_value_alloc(), and llcache_process_metadata().

Here is the caller graph for this function:

◆ cert_chain_dup()

nserror cert_chain_dup ( const struct cert_chain src,
struct cert_chain **  dst_out 
)

duplicate a certificate chain

Parameters
srcThe certificate chain to copy from
dst_outA pointer to recive the duplicated chain
Returns
NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion

Definition at line 101 of file ssl_certs.c.

References cert_chain_alloc(), cert_chain_free(), cert_chain::certs, cert_chain::depth, cert_chain::der, cert_chain::der_length, cert_chain::err, NSERROR_NOMEM, and NSERROR_OK.

Referenced by browser_window_callback(), llcache_fetch_callback(), and llcache_object_snapshot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cert_chain_dup_into()

nserror cert_chain_dup_into ( const struct cert_chain src,
struct cert_chain dst 
)

duplicate a certificate chain into an existing chain

Parameters
srcThe certificate chain to copy from
dstThe chain to overwrite with a copy of src
Returns
NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion

NOTE: if this returns NSERROR_NOMEM then the destination chain will have some amount of content and should be cleaned up with cert_chain_free.

Definition at line 64 of file ssl_certs.c.

References cert_chain::certs, cert_chain::depth, cert_chain::der, cert_chain::der_length, cert_chain::err, NSERROR_NOMEM, and NSERROR_OK.

◆ cert_chain_free()

nserror cert_chain_free ( struct cert_chain chain)

free a certificate chain

Parameters
chainThe certificate chain to free
Returns
NSERROR_OK on success

Definition at line 317 of file ssl_certs.c.

References cert_chain::certs, cert_chain::depth, cert_chain::der, and NSERROR_OK.

Referenced by browser_window_callback(), browser_window_content_ready(), browser_window_destroy_internal(), cert_chain_dup(), curl_fetch_ssl_value_destroy(), llcache_fetch_callback(), llcache_object_destroy(), llcache_process_metadata(), and navigate_internal_real().

Here is the caller graph for this function:

◆ cert_chain_from_query()

nserror cert_chain_from_query ( struct nsurl url,
struct cert_chain **  chain_out 
)

create a certificate chain from a fetch query string

Parameters
urlThe url to convert the query from
dst_outA pointer to recive the duplicated chain
Returns
NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion

Definition at line 169 of file ssl_certs.c.

References cert_chain_alloc(), cert_chain::depth, MIN_CERT_LEN, NSERROR_INVALID, NSERROR_NEED_DATA, NSERROR_OK, nsurl_get(), NSURL_QUERY, and process_query_section().

Here is the call graph for this function:

◆ cert_chain_size()

size_t cert_chain_size ( const struct cert_chain chain)

total number of data bytes in a chain

Parameters
chainThe chain to size
Returns
the number of bytes used by the chain

Definition at line 340 of file ssl_certs.c.

References cert_chain::certs, cert_chain::depth, cert_chain::der, and cert_chain::der_length.

Referenced by total_object_size().

Here is the caller graph for this function:

◆ cert_chain_to_query()

nserror cert_chain_to_query ( struct cert_chain chain,
struct nsurl **  url_out 
)

create a fetch query string from a certificate chain

Returns
NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion

Definition at line 226 of file ssl_certs.c.

References cert_chain::certs, cert_chain::depth, cert_chain::der, cert_chain::der_length, cert_chain::err, NSERROR_NOMEM, NSERROR_OK, NSERROR_UNKNOWN, nsurl_create(), and SSL_CERT_ERR_OK.

Referenced by browser_window__handle_bad_certs(), and browser_window_show_certificates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_query_section()

static nserror process_query_section ( const char *  str,
size_t  len,
struct cert_chain chain 
)
static

process a part of a query extracting the certificate of an error code

Definition at line 139 of file ssl_certs.c.

References cert_chain::certs, cert_chain::depth, cert_chain::der, cert_chain::der_length, cert_chain::err, MIN_CERT_LEN, and NSERROR_OK.

Referenced by cert_chain_from_query().

Here is the caller graph for this function: