From ad28a2bc5f9497965c4c598d95b5e2bbff88983e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 25 Jan 2022 23:38:15 +0000 Subject: Work around the deprecation of the old curve API in OpenSSL 3.0.0. --- src/modules/extra/m_ssl_openssl.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 4fac43a02..58e9e7514 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -102,7 +102,7 @@ #else # define INSPIRCD_OPENSSL_OPAQUE_BIO -# if OPENSSL_VERSION_NUMBER > 0x30000000L +# if OPENSSL_VERSION_NUMBER >= 0x30000000L # define INSPIRCD_OPENSSL_AUTO_DH # endif #endif @@ -207,9 +207,14 @@ namespace OpenSSL void SetECDH(const std::string& curvename) { int nid = OBJ_sn2nid(curvename.c_str()); - if (nid == 0) + if (nid == NID_undef) throw Exception("Unknown curve: " + curvename); +# if OPENSSL_VERSION_NUMBER >= 0x10101000L + ERR_clear_error(); + if (!SSL_CTX_set1_groups(ctx, &nid, 1)) + throw Exception("Couldn't set ECDH curve"); +# else EC_KEY* eckey = EC_KEY_new_by_curve_name(nid); if (!eckey) throw Exception("Unable to create EC key object"); @@ -219,6 +224,7 @@ namespace OpenSSL EC_KEY_free(eckey); if (!ret) throw Exception("Couldn't set ECDH parameters"); +# endif } #endif @@ -456,7 +462,7 @@ namespace OpenSSL } #ifndef OPENSSL_NO_ECDH - const std::string curvename = tag->getString("ecdhcurve", "prime256v1", 1); + const std::string curvename = tag->getString("ecdhcurve", "prime256v1"); if (!curvename.empty()) ctx.SetECDH(curvename); #endif -- cgit v1.3.1-10-gc9f91