aboutsummaryrefslogtreecommitdiffstats
path: root/modules/extra/ssl_openssl.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2025-09-30 21:45:55 +0100
committerGravatar Sadie Powell2025-09-30 21:46:44 +0100
commit72f9fa781f236112ca72fd3484315de8cf85e50d (patch)
tree3f2b8a3432e7d3343b32d9afdb14160faa70627e /modules/extra/ssl_openssl.cpp
parentFix some misc issues with the services module. (diff)
parentTweak a message to make it clear that its not always an error. (diff)
Merge branch 'insp4' into master.
Diffstat (limited to 'modules/extra/ssl_openssl.cpp')
-rw-r--r--modules/extra/ssl_openssl.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/modules/extra/ssl_openssl.cpp b/modules/extra/ssl_openssl.cpp
index b97ca690c..aee796fae 100644
--- a/modules/extra/ssl_openssl.cpp
+++ b/modules/extra/ssl_openssl.cpp
@@ -119,15 +119,10 @@ namespace OpenSSL
}
#ifndef OPENSSL_NO_ECDH
- void SetECDH(const std::string& curvename)
+ bool SetECDH(const std::string& grouplist)
{
- int nid = OBJ_sn2nid(curvename.c_str());
- if (nid == NID_undef)
- throw Exception("Unknown curve: " + curvename);
-
ERR_clear_error();
- if (!SSL_CTX_set1_groups(ctx, &nid, 1))
- throw Exception("Couldn't set ECDH curve");
+ return SSL_CTX_set1_groups_list(ctx, grouplist.c_str());
}
#endif
@@ -356,9 +351,12 @@ namespace OpenSSL
}
#ifndef OPENSSL_NO_ECDH
- const std::string curvename = tag->getString("ecdhcurve", "prime256v1");
- if (!curvename.empty())
- ctx.SetECDH(curvename);
+ const auto grouplist = tag->getString("ecdhgroups", tag->getString("ecdhcurve", "prime256v1"));
+ if (!grouplist.empty() && !ctx.SetECDH(grouplist))
+ {
+ ERR_print_errors_cb(error_callback, this);
+ throw Exception("Couldn't set ECDH groups: " + lasterr);
+ }
#endif
SetContextOptions("server", tag, ctx);
@@ -666,6 +664,11 @@ private:
// Calls our private SSLInfoCallback()
friend void StaticSSLInfoCallback(const SSL* ssl, int where, int rc);
+ static const char* UnknownIfNULL(const char* str)
+ {
+ return str ? str : "UNKNOWN";
+ }
+
public:
OpenSSLIOHook(const std::shared_ptr<IOHookProvider>& hookprov, StreamSocket* sock, SSL* session)
: SSLIOHook(hookprov)
@@ -814,7 +817,10 @@ public:
if (!IsHookReady())
return;
out.append(SSL_get_version(sess)).push_back('-');
- out.append(SSL_get_cipher(sess));
+#if OPENSSL_VERSION_NUMBER >= 0x30200000L
+ out.append(UnknownIfNULL(SSL_get0_group_name(sess))).push_back('-');
+#endif
+ out.append(UnknownIfNULL(SSL_get_cipher(sess)));
}
bool GetServerName(std::string& out) const override