#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 |
Definition in file ssl.c.
int ast_ssl_init | ( | void | ) |
Provided by ssl.c
Definition at line 77 of file ssl.c.
References ast_calloc, ast_mutex_init, ssl_lock(), ssl_locks, and ssl_threadid().
Referenced by main().
00078 { 00079 #ifdef HAVE_OPENSSL 00080 unsigned int i; 00081 00082 SSL_library_init(); 00083 SSL_load_error_strings(); 00084 ERR_load_crypto_strings(); 00085 ERR_load_BIO_strings(); 00086 OpenSSL_add_all_algorithms(); 00087 00088 /* Make OpenSSL thread-safe. */ 00089 00090 CRYPTO_set_id_callback(ssl_threadid); 00091 00092 ssl_num_locks = CRYPTO_num_locks(); 00093 if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) { 00094 return -1; 00095 } 00096 for (i = 0; i < ssl_num_locks; i++) { 00097 ast_mutex_init(&ssl_locks[i]); 00098 } 00099 CRYPTO_set_locking_callback(ssl_lock); 00100 00101 #endif /* HAVE_OPENSSL */ 00102 return 0; 00103 }
static void ssl_lock | ( | int | mode, | |
int | n, | |||
const char * | file, | |||
int | line | |||
) | [static] |
Definition at line 55 of file ssl.c.
References ast_log(), ast_mutex_lock, ast_mutex_unlock, LOG_ERROR, and ssl_locks.
Referenced by ast_ssl_init().
00056 { 00057 if (n < 0 || n >= ssl_num_locks) { 00058 ast_log(LOG_ERROR, "OpenSSL is full of LIES!!! - " 00059 "ssl_num_locks '%d' - n '%d'\n", 00060 ssl_num_locks, n); 00061 return; 00062 } 00063 00064 if (mode & CRYPTO_LOCK) { 00065 ast_mutex_lock(&ssl_locks[n]); 00066 } else { 00067 ast_mutex_unlock(&ssl_locks[n]); 00068 } 00069 }
static unsigned long ssl_threadid | ( | void | ) | [static] |
ast_mutex_t* ssl_locks [static] |
int ssl_num_locks [static] |