[Asterisk-code-review] libasteriskssl: Allow OpenSSL 1.0.2 configured with no-depre... (asterisk[13])
Joshua Colp
asteriskteam at digium.com
Tue May 29 12:07:41 CDT 2018
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9021 )
Change subject: libasteriskssl: Allow OpenSSL 1.0.2 configured with no-deprecated.
......................................................................
libasteriskssl: Allow OpenSSL 1.0.2 configured with no-deprecated.
Use CRYPTO_set_id_callback(.) only with OpenSSL 0.9.8 and older.
ASTERISK-27867
Change-Id: Iadd58d5bf6f538eb224203970a4e88e26f259655
---
M main/libasteriskssl.c
1 file changed, 22 insertions(+), 12 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
George Joseph: Looks good to me, approved
diff --git a/main/libasteriskssl.c b/main/libasteriskssl.c
index 41c6bcb..97ca769 100644
--- a/main/libasteriskssl.c
+++ b/main/libasteriskssl.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2009-2012, Digium, Inc.
+ * Copyright (C) 2009-2018, Digium, Inc.
*
* Russell Bryant <russell at digium.com>
*
@@ -23,28 +23,30 @@
* \author Russell Bryant <russell at digium.com>
*/
-/*** MODULEINFO
- <support_level>core</support_level>
- ***/
-
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-#include "asterisk/_private.h" /* ast_ssl_init() */
+#include "asterisk/_private.h" /* ast_ssl_init() */
#ifdef HAVE_OPENSSL
-#include <openssl/ssl.h>
-#include <openssl/err.h>
+#include <openssl/opensslv.h> /* for OPENSSL_VERSION_NUMBER */
#endif
#if defined(HAVE_OPENSSL) && \
- (!defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER))
+ (defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L)
-#include <dlfcn.h>
+#include <dlfcn.h> /* for dlerror, dlsym, RTLD_NEXT */
+#include <openssl/crypto.h> /* for CRYPTO_num_locks, CRYPTO_set_id_call... */
+#include <openssl/err.h> /* for ERR_free_strings */
+#include <openssl/ssl.h> /* for SSL_library_init, SSL_load_error_str... */
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
+#include <pthread.h> /* for pthread_self */
+#endif
-#include "asterisk/utils.h"
-#include "asterisk/lock.h"
+#include "asterisk/lock.h" /* for ast_mutex_t, ast_mutex_init, ast_mut... */
+#include "asterisk/logger.h" /* for ast_debug, ast_log, LOG_ERROR */
+#include "asterisk/utils.h" /* for ast_calloc */
#define get_OpenSSL_function(func) do { real_##func = dlsym(RTLD_NEXT, __stringify(func)); } while(0)
@@ -54,10 +56,12 @@
static int ssl_num_locks;
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
static unsigned long ssl_threadid(void)
{
return (unsigned long) pthread_self();
}
+#endif
static void ssl_lock(int mode, int n, const char *file, int line)
{
@@ -94,6 +98,7 @@
#endif
}
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
void CRYPTO_set_id_callback(unsigned long (*func)(void))
{
#if defined(AST_DEVMODE)
@@ -102,6 +107,7 @@
}
#endif
}
+#endif
void CRYPTO_set_locking_callback(void (*func)(int mode,int type, const char *file, int line))
{
@@ -127,7 +133,9 @@
{
unsigned int i;
int (*real_SSL_library_init)(void);
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
void (*real_CRYPTO_set_id_callback)(unsigned long (*)(void));
+#endif
void (*real_CRYPTO_set_locking_callback)(void (*)(int, int, const char *, int));
void (*real_SSL_load_error_strings)(void);
const char *errstr;
@@ -147,6 +155,7 @@
/* Make OpenSSL usage thread-safe. */
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
dlerror();
get_OpenSSL_function(CRYPTO_set_id_callback);
if ((errstr = dlerror()) != NULL) {
@@ -158,6 +167,7 @@
} else {
real_CRYPTO_set_id_callback(ssl_threadid);
}
+#endif
dlerror();
get_OpenSSL_function(CRYPTO_set_locking_callback);
--
To view, visit https://gerrit.asterisk.org/9021
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Iadd58d5bf6f538eb224203970a4e88e26f259655
Gerrit-Change-Number: 9021
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180529/3ced85ac/attachment.html>
More information about the asterisk-code-review
mailing list