26 #include <openssl/evp.h> 27 #include <openssl/pem.h> 42 ast_cli(a->
fd,
"No stir/shaken configuration found\n");
55 for (i = options; i; i = i->
next) {
70 int wordlen = strlen(word);
95 fp = fopen(path,
"r");
97 ast_log(
LOG_ERROR,
"Failed to read %s key file '%s'\n", priv ?
"private" :
"public", path);
113 key = X509_get_pubkey(cert);
122 ast_log(
LOG_ERROR,
"Failed to read %s key from file '%s'\n", priv ?
"private" :
"public", path);
127 if (EVP_PKEY_id(key) != EVP_PKEY_EC && EVP_PKEY_id(key) != EVP_PKEY_RSA) {
128 ast_log(
LOG_ERROR,
"%s key from '%s' must be of type EVP_PKEY_EC or EVP_PKEY_RSA\n",
129 priv ?
"Private" :
"Public", path);
144 ASN1_INTEGER *serial;
149 fp = fopen(path,
"r");
162 serial = X509_get_serialNumber(cert);
164 ast_log(
LOG_ERROR,
"Failed to get serial number from certificate %s\n", path);
170 bignum = ASN1_INTEGER_to_BN(serial,
NULL);
171 if (bignum ==
NULL) {
172 ast_log(
LOG_ERROR,
"Failed to convert serial to bignum for certificate %s\n", path);
182 serial_hex = BN_bn2hex(bignum);
188 ast_log(
LOG_ERROR,
"Failed to convert bignum to hex for certificate %s\n", path);
193 OPENSSL_free(serial_hex);
195 ast_log(
LOG_ERROR,
"Failed to dup serial from openssl for certificate %s\n", path);
char * stir_shaken_get_serial_number_x509(const char *path)
Gets the serial number in hex form from the X509 certificate at path.
struct ast_variable * next
struct ast_variable * ast_variable_list_sort(struct ast_variable *head)
Performs an in-place sort on the variable list by ascending name.
struct ast_variable * ast_sorcery_objectset_create2(const struct ast_sorcery *sorcery, const void *object, enum ast_sorcery_field_handler_flags flags)
Create an object set (KVP list) for an object.
Asterisk main include file. File version handling, generic pbx functions.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
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.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_strdup(str)
A wrapper for strdup()
void ast_cli(int fd, const char *fmt,...)
char * stir_shaken_tab_complete_name(const char *word, struct ao2_container *container)
Tab completion for name matching with STIR/SHAKEN CLI commands.
const char * ast_sorcery_object_get_type(const void *object)
Get the type of a sorcery object.
#define ao2_ref(o, delta)
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.
#define ao2_iterator_next(iter)
struct ast_sorcery * ast_stir_shaken_sorcery(void)
Retrieve the stir/shaken sorcery context.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Standard Command Line Interface.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
Sorcery Data Access Layer API.