aboutsummaryrefslogtreecommitdiffstats
path: root/modules/spanningtree/hmac.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2025-12-07 20:55:20 +0000
committerGravatar Sadie Powell2025-12-07 20:55:20 +0000
commit79c01cb2a2615fbcb2a568d5a49c6d470459cf45 (patch)
treebe0f4c84145b8902abec690e5885831a061407f3 /modules/spanningtree/hmac.cpp
parentAvoid using deprecated functions in ssl_openssl. (diff)
parentRelease v4.9.0. (diff)
Merge branch 'insp4' into master.
Diffstat (limited to 'modules/spanningtree/hmac.cpp')
-rw-r--r--modules/spanningtree/hmac.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/modules/spanningtree/hmac.cpp b/modules/spanningtree/hmac.cpp
index 4a97bb5a4..818248de7 100644
--- a/modules/spanningtree/hmac.cpp
+++ b/modules/spanningtree/hmac.cpp
@@ -3,7 +3,7 @@
*
* Copyright (C) 2014 Matthew Martin <phy1729@gmail.com>
* Copyright (C) 2013-2014 Attila Molnar <attilamolnar@hush.com>
- * Copyright (C) 2013, 2019, 2021-2024 Sadie Powell <sadie@witchery.services>
+ * Copyright (C) 2013, 2019, 2021-2023, 2025 Sadie Powell <sadie@witchery.services>
* Copyright (C) 2012 Robby <robby@chatbelgie.be>
* Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
* Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
@@ -73,38 +73,45 @@ bool TreeSocket::ComparePass(const Link& link, const std::string& theirs)
capab->auth_fingerprint = !link.Fingerprint.empty();
capab->auth_challenge = !capab->ourchallenge.empty() && !capab->theirchallenge.empty();
- std::string fp;
+ const auto* sslhook = SSLIOHook::IsSSL(this);
+ const auto* sslcert = sslhook ? sslhook->GetCertificate() : nullptr;
+ const auto sslcert_usable = sslcert && sslcert->IsUsable();
+ const auto fp = sslcert_usable ? sslcert->GetFingerprint() : "";
if (capab->auth_fingerprint)
{
- std::string badfps;
- auto foundfp = false;
-
- auto* sslhook = SSLIOHook::IsSSL(this);
- auto* sslcert = sslhook ? sslhook->GetCertificate() : nullptr;
- if (sslcert && sslcert->IsUsable())
+ std::string sslerror;
+ if (!sslhook)
+ sslerror = "not using TLS";
+ if (!sslcert)
+ sslerror = "not using a TLS client certificate";
+ else if (!sslcert_usable)
+ sslerror = "using an invalid (probably expired) TLS client certificate";
+ else
{
+ std::string badfps;
+ auto foundfp = false;
for (const auto& fingerprint : sslcert->GetFingerprints())
{
if (InspIRCd::TimingSafeCompare(link.Fingerprint, fingerprint))
{
- fp = fingerprint;
foundfp = true;
break;
}
-
badfps.append(badfps.empty() ? "" : ", ").append(fingerprint);
}
+ if (!foundfp)
+ {
+ sslerror = INSP_FORMAT("not using the correct TLS client certificate (need \"{}\" got \"{}\")",
+ link.Fingerprint, badfps.empty() ? "(none)" : badfps);
+ }
}
/* Require fingerprint to exist and match */
- if (!foundfp)
+ if (!sslerror.empty())
{
- if (badfps.empty())
- badfps = "(none)";
-
- ServerInstance->SNO.WriteToSnoMask('l', "Invalid TLS certificate fingerprint on link {}: need \"{}\" got \"{}\"",
- link.Name, link.Fingerprint, badfps);
- SendError("Invalid TLS certificate fingerprint: " + badfps);
+ ServerInstance->SNO.WriteToSnoMask('l', "Incorrect TLS client certificate on link {}: {}",
+ link.Name, sslerror);
+ SendError("Incorrect TLS client certificate: " + sslerror);
return false;
}
}
@@ -128,7 +135,7 @@ bool TreeSocket::ComparePass(const Link& link, const std::string& theirs)
// this time
if ((!capab->auth_fingerprint) && (!fp.empty()))
{
- ServerInstance->SNO.WriteToSnoMask('l', "TLS certificate fingerprint for link {} is \"{}\". "
+ ServerInstance->SNO.WriteToSnoMask('l', "TLS client certificate fingerprint for link {} is \"{}\". "
"You can improve security by specifying this in <link:fingerprint>.", link.Name, fp);
}