30 #define CONFIG_TYPE "certificate" 87 .
name =
"caller_id_number",
142 e->
command =
"stir_shaken show certificate";
144 "Usage: stir_shaken show certificate <id>\n" 145 " Show the certificate stir/shaken settings for a given id\n";
172 e->
command =
"stir_shaken show certificates";
174 "Usage: stir_shaken show certificates\n" 175 " Show all configured certificates for stir/shaken\n";
187 ast_cli(a->
fd,
"No stir/shaken certificates found\n");
208 if (stat(var->
value, &statbuf)) {
213 if (!S_ISREG(statbuf.st_mode)) {
235 ast_log(
LOG_ERROR,
"stir/shaken - public_cert_url scheme must be 'http[s]'\n");
255 if (strcmp(var->
value,
"A") && strcmp(var->
value,
"B") && strcmp(var->
value,
"C")) {
256 ast_log(
LOG_ERROR,
"stir/shaken - attestation level must be A, B, or C (object=%s)\n",
273 #ifdef TEST_FRAMEWORK 276 #define TEST_CONFIG_NAME "test_stir_shaken_certificate" 278 #define TEST_CONFIG_URL "http://testing123" 297 "'%s'\n", caller_id_number);
317 ast_log(
LOG_ERROR,
"Failed to insert STIR/SHAKEN test certificate mapping\n");
static int on_load_path(const struct aco_option *opt, struct ast_variable *var, void *obj)
static char * stir_shaken_certificate_show_all(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_CLI_DEFINE(fn, txt,...)
#define ast_sorcery_remove_wizard_mapping(sorcery, type, name)
Remove an object wizard mapping.
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static int on_load_public_cert_url(const struct aco_option *opt, struct ast_variable *var, void *obj)
descriptor for a cli entry.
#define ao2_callback(c, flags, cb_fn, arg)
Structure for variables, used for configurations and for channel variables.
EVP_PKEY * stir_shaken_read_key(const char *path, int priv)
Reads the public (or private) key from the specified path.
Perform no matching, return all objects.
Full structure for sorcery.
Type for a default handler that should do nothing.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Return all matching objects.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_sorcery_insert_wizard_mapping(sorcery, type, name, data, caching, position)
Insert an additional object wizard mapping at a specific position in the wizard list.
void ast_cli(int fd, const char *fmt,...)
static void * stir_shaken_certificate_alloc(const char *name)
const ast_string_field attestation
const char * stir_shaken_certificate_get_attestation(struct stir_shaken_certificate *cert)
Get the attestation level associated with a certificate.
static void stir_shaken_certificate_destructor(void *obj)
char * stir_shaken_tab_complete_name(const char *word, struct ao2_container *container)
Tab completion for name matching with STIR/SHAKEN CLI commands.
#define ast_strlen_zero(foo)
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
int stir_shaken_certificate_load(void)
Load time initialization for the stir/shaken 'certificate' configuration.
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
#define ast_sorcery_object_field_register_custom(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers.
static int public_cert_url_to_str(const void *obj, const intptr_t *args, char **buf)
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ao2_ref(o, delta)
int stir_shaken_certificate_unload(void)
Unload time cleanup for the stir/shaken 'certificate' configuration.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
struct ao2_container * container
int stir_shaken_cli_show(void *obj, void *arg, int flags)
Output configuration settings to the Asterisk CLI.
static struct ast_cli_entry stir_shaken_certificate_cli[]
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
int test_stir_shaken_create_cert(const char *caller_id_number, const char *file_path)
int ast_sorcery_delete(const struct ast_sorcery *sorcery, void *object)
Delete an object.
struct stir_shaken_certificate * stir_shaken_certificate_get_by_caller_id_number(const char *caller_id_number)
Get a STIR/SHAKEN certificate by caller ID number.
int test_stir_shaken_cleanup_cert(const char *caller_id_number)
#define ast_sorcery_apply_default(sorcery, type, name, data)
static struct stir_shaken_certificate * stir_shaken_certificate_get(const char *id)
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
static struct ao2_container * stir_shaken_certificate_get_all(void)
struct ast_sorcery * ast_stir_shaken_sorcery(void)
Retrieve the stir/shaken sorcery context.
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
const ast_string_field caller_id_number
const ast_string_field public_cert_url
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
static int path_to_str(const void *obj, const intptr_t *args, char **buf)
static struct ast_sorcery * sorcery
Standard Command Line Interface.
EVP_PKEY * stir_shaken_certificate_get_private_key(struct stir_shaken_certificate *cert)
Get the private key associated with a certificate.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
static int stir_shaken_certificate_apply(const struct ast_sorcery *sorcery, void *obj)
Type for default option handler for stringfields.
const ast_string_field path
static char * stir_shaken_certificate_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
static int attestation_to_str(const void *obj, const intptr_t *args, char **buf)
static int on_load_attestation(const struct aco_option *opt, struct ast_variable *var, void *obj)
const char * stir_shaken_certificate_get_public_cert_url(struct stir_shaken_certificate *cert)
Get the public key URL associated with a certificate.
Sorcery Data Access Layer API.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.