wget2  1.0.0
HTTP Public Key Pinning (RFC 7469) routines

Functions

void wget_hpkp_pin_add (wget_hpkp_t *hpkp, const char *pin_type, const char *pin_b64)
 
void wget_hpkp_free (wget_hpkp_t *hpkp)
 
wget_hpkp_t * wget_hpkp_new (void)
 
void wget_hpkp_set_host (wget_hpkp_t *hpkp, const char *host)
 
void wget_hpkp_set_maxage (wget_hpkp_t *hpkp, long maxage)
 
void wget_hpkp_set_include_subdomains (wget_hpkp_t *hpkp, int include_subdomains)
 
wget_hpkp_db_t * wget_hpkp_db_init (wget_hpkp_db_t *hpkp_db)
 
void wget_hpkp_db_deinit (wget_hpkp_db_t *hpkp_db)
 
void wget_hpkp_db_free (wget_hpkp_db_t **hpkp_db)
 
int wget_hpkp_db_check_pubkey (wget_hpkp_db_t *hpkp_db, const char *host, const void *pubkey, size_t pubkeysize)
 
void wget_hpkp_db_add (wget_hpkp_db_t *hpkp_db, wget_hpkp_t **_hpkp)
 
int wget_hpkp_db_load (wget_hpkp_db_t *hpkp_db, const char *fname)
 
int wget_hpkp_db_save (wget_hpkp_db_t *hpkp_db, const char *fname)
 

Detailed Description

This is an implementation of RFC 7469.

Function Documentation

◆ wget_hpkp_new()

wget_hpkp_t* wget_hpkp_new ( void  )
Parameters
[in]hostHost name the following information refers to
[in]portPort number the following information refers to
[in]max_ageValue of the max-age field
[in]include_subdomainsValue of the includeSubDomains field
Returns
A newly allocated and initialized HPKP structure

Creates a new HPKP structure initialized with the given values.

◆ wget_hpkp_db_init()

wget_hpkp_db_t* wget_hpkp_db_init ( wget_hpkp_db_t *  hpkp_db)
Returns
Handle (pointer) to an HPKP database

Initializes a new HPKP database.

◆ wget_hpkp_db_free()

void wget_hpkp_db_free ( wget_hpkp_db_t **  hpkp_db)
Parameters
[in]hpkp_dbPointer to the pointer of an HPKP database, provided by wget_hpkp_db_init()

Closes and frees the HPKP database. A double pointer is required because this function will set the handle (pointer) to the HPKP database to NULL to prevent potential use-after-free conditions.

◆ wget_hpkp_db_save()

int wget_hpkp_db_save ( wget_hpkp_db_t *  hpkp_db,
const char *  fname 
)
Parameters
[in]hpkp_dbHandle to an HPKP database, obtained with wget_hpkp_db_init()
[in]fnamePath to a file
Returns
The number of SPKIs written to the file, or a negative number on error.

Saves the current HPKP database to the specified file.

The information will be stored in a human-readable format for inspection, but it is discouraged to rely on it for external processing. In particular, no application other than wget2 should modify the contents of the file as the format might change between releases without notice.

This function returns the number of SPKIs written to the file, which is effectively equal to the number of SPKIs in the database when this function was called, and thus, might be zero. If the file specified by filename exists, all its contents will be overwritten with the current contents of the database. Otherwise, if the file exists but there are no SPKIs in the database, the file will be deleted to avoid leaving an empty file.

If the file cannot be opened for writing WGET_HPKP_ERROR_FILE_OPEN is returned, and WGET_HPKP_ERROR in any other case.