--- res/res_rtp_asterisk.c (Asterisk 15.4) +++ res/res_rtp_asterisk.c (working copy) @@ -42,7 +42,15 @@ #ifdef HAVE_OPENSSL_SRTP +#include +#include #include #include #include +#if !defined(OPENSSL_NO_ECDH) && (OPENSSL_VERSION_NUMBER >= 0x10000000L) +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif #endif @@ -1654,12 +1665,13 @@ X509 *certificate; }; -#ifdef HAVE_OPENSSL_EC - static void configure_dhparams(const struct ast_rtp *rtp, const struct ast_rtp_dtls_cfg *dtls_cfg) { +#if !defined(OPENSSL_NO_ECDH) && (OPENSSL_VERSION_NUMBER >= 0x10000000L) && (OPENSSL_VERSION_NUMBER < 0x10100000L) EC_KEY *ecdh; +#endif +#ifndef OPENSSL_NO_DH if (!ast_strlen_zero(dtls_cfg->pvtfile)) { BIO *bio = BIO_new_file(dtls_cfg->pvtfile, "r"); if (bio) { @@ -1676,7 +1688,9 @@ BIO_free(bio); } } +#endif +#if !defined(OPENSSL_NO_ECDH) && (OPENSSL_VERSION_NUMBER >= 0x10000000L) && (OPENSSL_VERSION_NUMBER < 0x10100000L) /* enables AES-128 ciphers, to get AES-256 use NID_secp384r1 */ ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); if (ecdh) { @@ -1693,8 +1707,11 @@ } EC_KEY_free(ecdh); } +#endif } +#if !defined(OPENSSL_NO_ECDH) && (OPENSSL_VERSION_NUMBER >= 0x10000000L) + static int create_ephemeral_ec_keypair(EVP_PKEY **keypair) { EC_KEY *eckey = NULL; @@ -1770,10 +1787,17 @@ * Validity period - Current Chrome & Firefox make it 31 days starting * with yesterday at the current time, so we will do the same. */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L if (!X509_time_adj_ex(X509_get_notBefore(cert), -1, 0, NULL) || !X509_time_adj_ex(X509_get_notAfter(cert), 30, 0, NULL)) { goto error; } +#else + if (!X509_time_adj_ex(X509_getm_notBefore(cert), -1, 0, NULL) + || !X509_time_adj_ex(X509_getm_notAfter(cert), 30, 0, NULL)) { + goto error; + } +#endif /* Set the name and issuer */ if (!(name = X509_get_subject_name(cert)) @@ -1828,10 +1852,6 @@ #else -static void configure_dhparams(const struct ast_rtp *rtp, const struct ast_rtp_dtls_cfg *dtls_cfg) -{ -} - static int create_certificate_ephemeral(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg, struct dtls_cert_info *cert_info) @@ -1840,7 +1860,7 @@ return -1; } -#endif /* HAVE_OPENSSL_EC */ +#endif /* !OPENSSL_NO_ECDH */ static int create_certificate_from_file(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg,