mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 21:22:09 +00:00
FS-9785: changes to support newer openssl
This commit is contained in:
+56
-2
@@ -3284,10 +3284,18 @@ static int cb_verify_peer(int preverify_ok, X509_STORE_CTX *ctx)
|
||||
|
||||
////////////
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
static BIO_METHOD dtls_bio_filter_methods;
|
||||
#else
|
||||
static BIO_METHOD *dtls_bio_filter_methods;
|
||||
#endif
|
||||
|
||||
BIO_METHOD *BIO_dtls_filter(void) {
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
return(&dtls_bio_filter_methods);
|
||||
#else
|
||||
return(dtls_bio_filter_methods);
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct packet_list_s {
|
||||
@@ -3320,10 +3328,16 @@ static int dtls_bio_filter_new(BIO *bio) {
|
||||
switch_mutex_init(&filter->mutex, SWITCH_MUTEX_NESTED, filter->pool);
|
||||
|
||||
/* Set the BIO as initialized */
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
bio->init = 1;
|
||||
bio->ptr = filter;
|
||||
bio->flags = 0;
|
||||
|
||||
#else
|
||||
BIO_set_init(bio, 1);
|
||||
BIO_set_data(bio, filter);
|
||||
BIO_clear_flags(bio, ~0);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3335,7 +3349,11 @@ static int dtls_bio_filter_free(BIO *bio) {
|
||||
}
|
||||
|
||||
/* Get rid of the filter state */
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
filter = (dtls_bio_filter *)bio->ptr;
|
||||
#else
|
||||
filter = (dtls_bio_filter *)BIO_get_data(bio);
|
||||
#endif
|
||||
|
||||
if (filter != NULL) {
|
||||
switch_memory_pool_t *pool = filter->pool;
|
||||
@@ -3344,9 +3362,15 @@ static int dtls_bio_filter_free(BIO *bio) {
|
||||
filter = NULL;
|
||||
}
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
bio->ptr = NULL;
|
||||
bio->init = 0;
|
||||
bio->flags = 0;
|
||||
#else
|
||||
BIO_set_init(bio, 0);
|
||||
BIO_set_data(bio, NULL);
|
||||
BIO_clear_flags(bio, ~0);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3356,11 +3380,20 @@ static int dtls_bio_filter_write(BIO *bio, const char *in, int inl) {
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "dtls_bio_filter_write: %p, %d\n", (void *)in, inl);
|
||||
/* Forward data to the write BIO */
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
ret = BIO_write(bio->next_bio, in, inl);
|
||||
#else
|
||||
ret = BIO_write(BIO_next(bio), in, inl);
|
||||
#endif
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, " -- %ld\n", ret);
|
||||
|
||||
/* Keep track of the packet, as we'll advertize them one by one after a pending check */
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
filter = (dtls_bio_filter *)bio->ptr;
|
||||
#else
|
||||
filter = (dtls_bio_filter *)BIO_get_data(bio);
|
||||
#endif
|
||||
|
||||
if (filter != NULL) {
|
||||
packet_list_t *node;
|
||||
@@ -3391,7 +3424,11 @@ static int dtls_bio_filter_write(BIO *bio, const char *in, int inl) {
|
||||
}
|
||||
|
||||
static long dtls_bio_filter_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
dtls_bio_filter *filter = (dtls_bio_filter *)bio->ptr;
|
||||
#else
|
||||
dtls_bio_filter *filter = (dtls_bio_filter *)BIO_get_data(bio);
|
||||
#endif
|
||||
|
||||
switch(cmd) {
|
||||
case BIO_CTRL_DGRAM_GET_FALLBACK_MTU:
|
||||
@@ -3438,6 +3475,7 @@ static long dtls_bio_filter_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
static BIO_METHOD dtls_bio_filter_methods = {
|
||||
BIO_TYPE_FILTER,
|
||||
"DTLS filter",
|
||||
@@ -3450,7 +3488,9 @@ static BIO_METHOD dtls_bio_filter_methods = {
|
||||
dtls_bio_filter_free,
|
||||
NULL
|
||||
};
|
||||
|
||||
#else
|
||||
static BIO_METHOD *dtls_bio_filter_methods = NULL;
|
||||
#endif
|
||||
|
||||
///////////
|
||||
|
||||
@@ -3598,7 +3638,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, d
|
||||
|
||||
dtls->ca = switch_core_sprintf(rtp_session->pool, "%s%sca-bundle.crt", SWITCH_GLOBAL_dirs.certs_dir, SWITCH_PATH_SEPARATOR);
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000
|
||||
dtls->ssl_ctx = SSL_CTX_new((type & DTLS_TYPE_SERVER) ? DTLS_server_method() : DTLS_client_method());
|
||||
#else
|
||||
dtls->ssl_ctx = SSL_CTX_new((type & DTLS_TYPE_SERVER) ? DTLSv1_server_method() : DTLSv1_client_method());
|
||||
#endif
|
||||
switch_assert(dtls->ssl_ctx);
|
||||
|
||||
bio = BIO_new_file(dtls->pem, "r");
|
||||
@@ -3659,7 +3703,17 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, d
|
||||
|
||||
dtls->ssl = SSL_new(dtls->ssl_ctx);
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
dtls->filter_bio = BIO_new(BIO_dtls_filter());
|
||||
#else
|
||||
dtls_bio_filter_methods = BIO_meth_new(BIO_TYPE_FILTER | BIO_get_new_index(), "DTLS filter");
|
||||
BIO_meth_set_write(dtls_bio_filter_methods, dtls_bio_filter_write);
|
||||
BIO_meth_set_ctrl(dtls_bio_filter_methods, dtls_bio_filter_ctrl);
|
||||
BIO_meth_set_create(dtls_bio_filter_methods, dtls_bio_filter_new);
|
||||
BIO_meth_set_destroy(dtls_bio_filter_methods, dtls_bio_filter_free);
|
||||
dtls->filter_bio = BIO_new(dtls_bio_filter_methods);
|
||||
#endif
|
||||
|
||||
switch_assert(dtls->filter_bio);
|
||||
|
||||
BIO_push(dtls->filter_bio, dtls->write_bio);
|
||||
|
||||
Reference in New Issue
Block a user