diff options
| author | 2022-01-25 23:38:15 +0000 | |
|---|---|---|
| committer | 2022-01-25 23:47:19 +0000 | |
| commit | ad28a2bc5f9497965c4c598d95b5e2bbff88983e (patch) | |
| tree | e1b017af1f9348299f08de3b50b0c563ac7be733 /src/modules | |
| parent | Work around the deprecation of manual DH params in OpenSSL 3.0.0. (diff) | |
| download | inspircd++-ad28a2bc5f9497965c4c598d95b5e2bbff88983e.tar.gz inspircd++-ad28a2bc5f9497965c4c598d95b5e2bbff88983e.tar.bz2 inspircd++-ad28a2bc5f9497965c4c598d95b5e2bbff88983e.zip | |
Work around the deprecation of the old curve API in OpenSSL 3.0.0.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
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 |
