Files
asterisk/res/res_stir_shaken/certificate.h
Ben Ford 259ecfa289 STIR/SHAKEN: Fix certificate type and storage.
During OpenSIPit, we found out that the public certificates must be of
type X.509. When reading in public keys, we use the corresponding X.509
functions now.

We also discovered that we needed a better naming scheme for the
certificates since certificates with the same name would cause issues
(overwriting certs, etc.). Now when we download a public certificate, we
get the serial number from it and use that as the name of the cached
certificate.

The configuration option public_key_url in stir_shaken.conf has also
been renamed to public_cert_url, which better describes what the option
is for.

https://wiki.asterisk.org/wiki/display/AST/OpenSIPit+2021

Change-Id: Ia00b20835f5f976e3603797f2f2fb19672d8114d
2021-05-11 09:29:57 -05:00

120 lines
3.2 KiB
C

/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2020, Sangoma Technologies Corporation
*
* Kevin Harwell <kharwell@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_CERTIFICATE_H
#define _STIR_SHAKEN_CERTIFICATE_H
#include <openssl/evp.h>
struct ast_sorcery;
struct stir_shaken_certificate;
/*!
* \brief Get a STIR/SHAKEN certificate by caller ID number
*
* \param callier_id_number The caller ID number
*
* \retval NULL if not found
* \retval The certificate on success
*/
struct stir_shaken_certificate *stir_shaken_certificate_get_by_caller_id_number(const char *caller_id_number);
/*!
* \brief Get the public key URL associated with a certificate
*
* \param cert The certificate to get the public key URL from
*
* \retval NULL on failure
* \retval The public key URL on success
*/
const char *stir_shaken_certificate_get_public_cert_url(struct stir_shaken_certificate *cert);
/*!
* \brief Get the attestation level associated with a certificate
*
* \param cert The certificate
*
* \retval NULL on failure
* \retval The attestation on success
*/
const char *stir_shaken_certificate_get_attestation(struct stir_shaken_certificate *cert);
/*!
* \brief Get the origination ID associated with a certificate
*
* \param cert The certificate
*
* \retval NULL on failure
* \retval The origid on success
*/
const char *stir_shaken_certificate_get_origid(struct stir_shaken_certificate *cert);
/*!
* \brief Get the private key associated with a certificate
*
* \param cert The certificate to get the private key from
*
* \retval NULL on failure
* \retval The private key on success
*/
EVP_PKEY *stir_shaken_certificate_get_private_key(struct stir_shaken_certificate *cert);
#ifdef TEST_FRAMEWORK
/*!
* \brief Clean up the certificate and mappings set up in test_stir_shaken_init
*
* \param caller_id_number The caller ID of the certificate to clean up
*
* \retval non-zero on failure
* \retval 0 on success
*/
int test_stir_shaken_cleanup_cert(const char *caller_id_number);
/*!
* \brief Initialize a test certificate through wizard mappings
*
* \note test_stir_shaken_cleanup should be called when done with this certificate
*
* \param caller_id_number The caller ID of the certificate to create
* \param file_path The path to the private key for this certificate
*
* \retval non-zero on failure
* \retval 0 on success
*/
int test_stir_shaken_create_cert(const char *caller_id_number, const char *file_path);
#endif /* TEST_FRAMEWORK */
/*!
* \brief Load time initialization for the stir/shaken 'certificate' configuration
*
* \retval 0 on success, -1 on error
*/
int stir_shaken_certificate_load(void);
/*!
* \brief Unload time cleanup for the stir/shaken 'certificate' configuration
*
* \retval 0 on success, -1 on error
*/
int stir_shaken_certificate_unload(void);
#endif /* _STIR_SHAKEN_CERTIFICATE_H */