Common OpenSSL support code. More...
#include "asterisk.h"#include <openssl/ssl.h>#include <openssl/err.h>#include "asterisk/_private.h"#include "asterisk/utils.h"#include "asterisk/lock.h"
Go to the source code of this file.
Functions | |
| int | ast_ssl_init (void) |
| static void | ssl_lock (int mode, int n, const char *file, int line) |
| static unsigned long | ssl_threadid (void) |
Variables | |
| static ast_mutex_t * | ssl_locks |
| static int | ssl_num_locks |
Common OpenSSL support code.
Definition in file ssl.c.
| int ast_ssl_init | ( | void | ) |
Provided by ssl.c
Definition at line 73 of file ssl.c.
References ast_calloc, ast_mutex_init, ssl_lock(), ssl_num_locks, and ssl_threadid().
Referenced by main().
{
#ifdef HAVE_OPENSSL
unsigned int i;
SSL_library_init();
SSL_load_error_strings();
ERR_load_crypto_strings();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
/* Make OpenSSL thread-safe. */
CRYPTO_set_id_callback(ssl_threadid);
ssl_num_locks = CRYPTO_num_locks();
if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) {
return -1;
}
for (i = 0; i < ssl_num_locks; i++) {
ast_mutex_init(&ssl_locks[i]);
}
CRYPTO_set_locking_callback(ssl_lock);
#endif /* HAVE_OPENSSL */
return 0;
}
| static void ssl_lock | ( | int | mode, |
| int | n, | ||
| const char * | file, | ||
| int | line | ||
| ) | [static] |
Definition at line 51 of file ssl.c.
References ast_log(), ast_mutex_lock, ast_mutex_unlock, and LOG_ERROR.
Referenced by ast_ssl_init().
{
if (n < 0 || n >= ssl_num_locks) {
ast_log(LOG_ERROR, "OpenSSL is full of LIES!!! - "
"ssl_num_locks '%d' - n '%d'\n",
ssl_num_locks, n);
return;
}
if (mode & CRYPTO_LOCK) {
ast_mutex_lock(&ssl_locks[n]);
} else {
ast_mutex_unlock(&ssl_locks[n]);
}
}
| static unsigned long ssl_threadid | ( | void | ) | [static] |
Definition at line 46 of file ssl.c.
Referenced by ast_ssl_init().
{
return (unsigned long)pthread_self();
}
ast_mutex_t* ssl_locks [static] |
int ssl_num_locks [static] |
Definition at line 44 of file ssl.c.
Referenced by ast_ssl_init().