Common OpenSSL support code.
More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include <openssl/opensslv.h>
#include <dlfcn.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <pthread.h>
#include "asterisk/lock.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
Go to the source code of this file.
|
#define | get_OpenSSL_function(func) do { real_##func = dlsym(RTLD_NEXT, __stringify(func)); } while(0) |
|
|
int | ast_ssl_init (void) |
|
void | CRYPTO_set_id_callback (unsigned long(*func)(void)) |
|
void | CRYPTO_set_locking_callback (void(*func)(int mode, int type, const char *file, int line)) |
|
void | ERR_free_strings (void) |
|
int | SSL_library_init (void) |
|
void | SSL_load_error_strings (void) |
|
static void | ssl_lock (int mode, int n, const char *file, int line) |
|
static unsigned long | ssl_threadid (void) |
|
|
static ast_mutex_t * | ssl_locks |
|
static int | ssl_num_locks |
|
static int | startup_complete |
|
Common OpenSSL support code.
- Author
- Russell Bryant russe.nosp@m.ll@d.nosp@m.igium.nosp@m..com
Definition in file libasteriskssl.c.
int ast_ssl_init |
( |
void |
| ) |
|
Provided by ssl.c
Definition at line 130 of file libasteriskssl.c.
References ast_calloc, and ast_debug.
133 int (*real_SSL_library_init)(void);
134 #if OPENSSL_VERSION_NUMBER < 0x10000000L
135 void (*real_CRYPTO_set_id_callback)(
unsigned long (*)(void));
137 void (*real_CRYPTO_set_locking_callback)(void (*)(int, int,
const char *, int));
138 void (*real_SSL_load_error_strings)(void);
143 get_OpenSSL_function(SSL_library_init);
144 if ((errstr = dlerror()) != NULL) {
145 ast_debug(1,
"unable to get real address of SSL_library_init: %s\n", errstr);
151 real_SSL_library_init();
156 #if OPENSSL_VERSION_NUMBER < 0x10000000L
158 get_OpenSSL_function(CRYPTO_set_id_callback);
159 if ((errstr = dlerror()) != NULL) {
160 ast_debug(1,
"unable to get real address of CRYPTO_set_id_callback: %s\n", errstr);
166 real_CRYPTO_set_id_callback(ssl_threadid);
171 get_OpenSSL_function(CRYPTO_set_locking_callback);
172 if ((errstr = dlerror()) != NULL) {
173 ast_debug(1,
"unable to get real address of CRYPTO_set_locking_callback: %s\n", errstr);
179 ssl_num_locks = CRYPTO_num_locks();
180 if (!(ssl_locks =
ast_calloc(ssl_num_locks,
sizeof(ssl_locks[0])))) {
183 for (i = 0; i < ssl_num_locks; i++) {
184 ast_mutex_init(&ssl_locks[i]);
186 real_CRYPTO_set_locking_callback(ssl_lock);
195 get_OpenSSL_function(SSL_load_error_strings);
196 real_SSL_load_error_strings();
198 startup_complete = 1;
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_calloc(num, len)
A wrapper for calloc()