Wed Jan 8 2020 09:50:21

Asterisk developer's documentation


ssl.c File Reference

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_tssl_locks
 
static int ssl_num_locks
 

Detailed Description

Common OpenSSL support code.

Author
Russell Bryant russe.nosp@m.ll@d.nosp@m.igium.nosp@m..com

Definition in file ssl.c.

Function Documentation

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_num_locks, and ssl_threadid().

Referenced by main().

78 {
79 #ifdef HAVE_OPENSSL
80  unsigned int i;
81 
82  SSL_library_init();
83  SSL_load_error_strings();
84  ERR_load_BIO_strings();
85 
86  /* Make OpenSSL thread-safe. */
87 
88  CRYPTO_set_id_callback(ssl_threadid);
89 
90  ssl_num_locks = CRYPTO_num_locks();
91  if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) {
92  return -1;
93  }
94  for (i = 0; i < ssl_num_locks; i++) {
96  }
97  CRYPTO_set_locking_callback(ssl_lock);
98 
99 #endif /* HAVE_OPENSSL */
100  return 0;
101 }
static void ssl_lock(int mode, int n, const char *file, int line)
Definition: ssl.c:55
static int ssl_num_locks
Definition: ssl.c:48
static unsigned long ssl_threadid(void)
Definition: ssl.c:50
static ast_mutex_t * ssl_locks
Definition: ssl.c:46
#define ast_calloc(a, b)
Definition: astmm.h:82
#define ast_mutex_init(pmutex)
Definition: lock.h:152
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, and LOG_ERROR.

Referenced by ast_ssl_init().

56 {
57  if (n < 0 || n >= ssl_num_locks) {
58  ast_log(LOG_ERROR, "OpenSSL is full of LIES!!! - "
59  "ssl_num_locks '%d' - n '%d'\n",
60  ssl_num_locks, n);
61  return;
62  }
63 
64  if (mode & CRYPTO_LOCK) {
66  } else {
68  }
69 }
static int ssl_num_locks
Definition: ssl.c:48
#define ast_mutex_lock(a)
Definition: lock.h:155
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static ast_mutex_t * ssl_locks
Definition: ssl.c:46
#define ast_mutex_unlock(a)
Definition: lock.h:156
static unsigned long ssl_threadid ( void  )
static

Definition at line 50 of file ssl.c.

Referenced by ast_ssl_init().

51 {
52  return (unsigned long)pthread_self();
53 }

Variable Documentation

ast_mutex_t* ssl_locks
static

Definition at line 46 of file ssl.c.

int ssl_num_locks
static

Definition at line 48 of file ssl.c.

Referenced by ast_ssl_init().