res_rtp_asterisk: Instead of ./configure use OPENSSL_NO_SRTP.

Previously, Asterisk used its script ./configure, to test whether OpenSSL was
built with no-srtp (or was simply too old). However, the header file
<openssl/opensslconf.h> is the preferred way to detect the local configuration
of OpenSSL.

As a positive side-effect the script ./configure does not interleave the
detection of the Open Settlement Protocol Toolkit (OSPTK) with the detection of
individual features of OpenSSL anymore.

Change-Id: I3c77c7b00b2ffa2e935632097fa057b9fdf480c0
This commit is contained in:
Alexander Traud
2018-06-13 12:14:18 +02:00
parent 49c4c8af98
commit e3de4bc46e
3 changed files with 21 additions and 116 deletions

View File

@@ -42,9 +42,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <signal.h>
#include <fcntl.h>
#ifdef HAVE_OPENSSL_SRTP
#ifdef HAVE_OPENSSL
#include <openssl/opensslconf.h>
#include <openssl/opensslv.h>
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/bio.h>
@@ -52,6 +53,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <openssl/dh.h>
#endif
#endif
#endif
#ifdef HAVE_PJPROJECT
#include <pjlib.h>
@@ -268,7 +270,7 @@ struct rtp_learning_info {
enum ast_media_type stream_type;
};
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
struct dtls_details {
SSL *ssl; /*!< SSL session */
BIO *read_bio; /*!< Memory buffer for reading */
@@ -391,7 +393,7 @@ struct ast_rtp {
unsigned int ice_num_components; /*!< The number of ICE components */
#endif
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
SSL_CTX *ssl_ctx; /*!< SSL context */
enum ast_rtp_dtls_verify dtls_verify; /*!< What to verify */
enum ast_srtp_suite suite; /*!< SRTP crypto suite */
@@ -468,7 +470,7 @@ struct ast_rtcp {
/* VP8: sequence number for the RTCP FIR FCI */
int firseq;
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
struct dtls_details dtls; /*!< DTLS state information */
#endif
@@ -522,7 +524,7 @@ static void ast_rtp_stop(struct ast_rtp_instance *instance);
static int ast_rtp_qos_set(struct ast_rtp_instance *instance, int tos, int cos, const char* desc);
static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level);
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
static int ast_rtp_activate(struct ast_rtp_instance *instance);
static void dtls_srtp_check_pending(struct ast_rtp_instance *instance, struct ast_rtp *rtp, int rtcp);
static void dtls_srtp_start_timeout_timer(struct ast_rtp_instance *instance, struct ast_rtp *rtp, int rtcp);
@@ -1541,7 +1543,7 @@ static struct ast_rtp_engine_ice ast_rtp_ice = {
};
#endif
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
static int dtls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
{
/* We don't want to actually verify the certificate so just accept what they have provided */
@@ -1997,13 +1999,13 @@ static struct ast_rtp_engine asterisk_rtp_engine = {
#ifdef HAVE_PJPROJECT
.ice = &ast_rtp_ice,
#endif
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
.dtls = &ast_rtp_dtls,
.activate = ast_rtp_activate,
#endif
};
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
/*! \pre instance is locked */
static void dtls_perform_handshake(struct ast_rtp_instance *instance, struct dtls_details *dtls, int rtcp)
{
@@ -2064,7 +2066,7 @@ static void ast_rtp_on_ice_complete(pj_ice_sess *ice, pj_status_t status)
}
}
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
dtls_perform_handshake(instance, &rtp->dtls, 0);
if (rtp->rtcp && rtp->rtcp->type == AST_RTP_INSTANCE_RTCP_STANDARD) {
@@ -2195,7 +2197,7 @@ static inline int rtcp_debug_test_addr(struct ast_sockaddr *addr)
return 1;
}
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
/*! \pre instance is locked */
static int dtls_srtp_handle_timeout(struct ast_rtp_instance *instance, int rtcp)
{
@@ -2519,7 +2521,7 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
return len;
}
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
/* If this is an SSL packet pass it to OpenSSL for processing. RFC section for first byte value:
* https://tools.ietf.org/html/rfc5764#section-5.1.2 */
if ((*in >= 20) && (*in <= 63)) {
@@ -3223,7 +3225,7 @@ static int ast_rtp_new(struct ast_rtp_instance *instance,
/* Record any information we may need */
rtp->sched = sched;
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
rtp->rekeyid = -1;
rtp->dtls.timeout_timer = -1;
#endif
@@ -3244,7 +3246,7 @@ static int ast_rtp_destroy(struct ast_rtp_instance *instance)
struct timespec ts = { .tv_sec = wait.tv_sec, .tv_nsec = wait.tv_usec * 1000, };
#endif
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
ast_rtp_dtls_stop(instance);
#endif
@@ -5859,7 +5861,7 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro
return;
}
rtp->rtcp->s = -1;
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
rtp->rtcp->dtls.timeout_timer = -1;
#endif
rtp->rtcp->schedid = -1;
@@ -5922,7 +5924,7 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro
rtp_add_candidates_to_ice(instance, rtp, &rtp->rtcp->us, ast_sockaddr_port(&rtp->rtcp->us), AST_RTP_ICE_COMPONENT_RTCP, TRANSPORT_SOCKET_RTCP);
}
#endif
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
dtls_setup_rtcp(instance);
#endif
} else {
@@ -5942,7 +5944,7 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro
rtp->rtcp->s = rtp->s;
ast_rtp_instance_get_remote_address(instance, &addr);
ast_sockaddr_copy(&rtp->rtcp->them, &addr);
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
if (rtp->rtcp->dtls.ssl && rtp->rtcp->dtls.ssl != rtp->dtls.ssl) {
SSL_free(rtp->rtcp->dtls.ssl);
}
@@ -5970,7 +5972,7 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro
if (rtp->rtcp->s > -1 && rtp->rtcp->s != rtp->s) {
close(rtp->rtcp->s);
}
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
ao2_unlock(instance);
dtls_srtp_stop_timeout_timer(instance, rtp, 1);
ao2_lock(instance);
@@ -6212,7 +6214,7 @@ static void ast_rtp_stop(struct ast_rtp_instance *instance)
struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
struct ast_sockaddr addr = { {0,} };
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
ao2_unlock(instance);
AST_SCHED_DEL_UNREF(rtp->sched, rtp->rekeyid, ao2_ref(instance, -1));
@@ -6307,7 +6309,7 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
return res;
}
#ifdef HAVE_OPENSSL_SRTP
#if !defined(OPENSSL_NO_SRTP) && (OPENSSL_VERSION_NUMBER >= 0x10001000L)
static void dtls_perform_setup(struct dtls_details *dtls)
{
if (!dtls->ssl || !SSL_is_init_finished(dtls->ssl)) {