diff options
| author | 2023-03-01 20:07:27 +0000 | |
|---|---|---|
| committer | 2023-03-01 20:45:07 +0000 | |
| commit | 4e1d7b84f5415e9901ec18c0ed4cb012376e4859 (patch) | |
| tree | 501fbd35bd143357ee4a5b5da7c67ea8665a99d4 /src/modules/m_sslinfo.cpp | |
| parent | Add client cert activation/expiration times to the ssl_cert class. (diff) | |
Warn users when their client certificate is about to expire.
Closes #1938.
Diffstat (limited to 'src/modules/m_sslinfo.cpp')
| -rw-r--r-- | src/modules/m_sslinfo.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index f7f970a9d..309a99a64 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -253,6 +253,7 @@ class ModuleSSLInfo private: CommandSSLInfo cmd; std::string hash; + unsigned long warnexpiring; bool MatchFP(ssl_cert* const cert, const std::string& fp) const { @@ -273,6 +274,7 @@ class ModuleSSLInfo ConfigTag* tag = ServerInstance->Config->ConfValue("sslinfo"); cmd.operonlyfp = tag->getBool("operonly"); hash = tag->getString("hash"); + warnexpiring = tag->getDuration("warnexpiring", 0, 0, 60*60*24*365); } Version GetVersion() CXX11_OVERRIDE @@ -386,6 +388,19 @@ class ModuleSSLInfo if (do_login) user->Oper(ifo); } + + if (!warnexpiring || !cert->GetExpirationTime()) + return; + + if (ServerInstance->Time() > cert->GetExpirationTime()) + { + user->WriteNotice("*** Your TLS (SSL) client certificate has expired."); + } + else if (static_cast<time_t>(ServerInstance->Time() + warnexpiring) > cert->GetExpirationTime()) + { + const std::string duration = InspIRCd::DurationString(cert->GetExpirationTime() - ServerInstance->Time()); + user->WriteNotice("*** Your TLS (SSL) client certificate expires in " + duration + "."); + } } ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass) CXX11_OVERRIDE |
