There are a lot of moving parts in this patch, but the focus of it is on the verification of the signature using a public key located at the public key URL provided in the JSON payload. First, we check the database to see if we have already downloaded the key. If so, check to see if it has expired. If it has, redownload from the URL. If we don't have an entry in the database, just go ahead and download the public key. The expiration is tested each time we download the file. After that, read the public key from the file and use it to verify the signature. All sanity checking is done when the payload is first received, so the verification is complete once this point is reached. The XML has also been added since a new config option was added to general (curl_timeout). The maximum amount of time to wait for a download can be configured through this option, with a low value by default. Change-Id: I3ba4c63880493bf8c7d17a9cfca1af0e934d1a1c
74 lines
1.9 KiB
C
74 lines
1.9 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2020, Sangoma Technologies Corporation
|
|
*
|
|
* Ben Ford <bford@sangoma.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
#ifndef _STIR_SHAKEN_CURL_H
|
|
#define _STIR_SHAKEN_CURL_H
|
|
|
|
/* Forward declarion for CURL callback data */
|
|
struct curl_cb_data;
|
|
|
|
/*!
|
|
* \brief Allocate memory for a curl_cb_data struct
|
|
*
|
|
* \note This will need to be freed by the consumer using curl_cb_data_free
|
|
*
|
|
* \retval NULL on failure
|
|
* \retval curl_cb_struct on success
|
|
*/
|
|
struct curl_cb_data *curl_cb_data_create(void);
|
|
|
|
/*!
|
|
* \brief Free a curl_cb_data struct
|
|
*
|
|
* \param data The curl_cb_data struct to free
|
|
*/
|
|
void curl_cb_data_free(struct curl_cb_data *data);
|
|
|
|
/*!
|
|
* \brief Get the cache_control field from a curl_cb_data struct
|
|
*
|
|
* \param data The curl_cb_data
|
|
*
|
|
* \retval cache_control on success
|
|
* \retval NULL otherwise
|
|
*/
|
|
char *curl_cb_data_get_cache_control(const struct curl_cb_data *data);
|
|
|
|
/*!
|
|
* \brief Get the expires field from a curl_cb_data struct
|
|
*
|
|
* \param data The curl_cb_data
|
|
*
|
|
* \retval expires on success
|
|
* \retval NULL otherwise
|
|
*/
|
|
char *curl_cb_data_get_expires(const struct curl_cb_data *data);
|
|
|
|
/*!
|
|
* \brief CURL the public key from the provided URL to the specified path
|
|
*
|
|
* \param public_key_url The public key URL
|
|
* \param path The path to download the file to
|
|
* \param data The curl_cb_data
|
|
*
|
|
* \retval 1 on failure
|
|
* \retval 0 on success
|
|
*/
|
|
int curl_public_key(const char *public_key_url, const char *path, struct curl_cb_data *data);
|
|
|
|
#endif /* _STIR_SHAKEN_CURL_H */
|