diff --git a/ChangeLog.md b/ChangeLog.md index fb82f6fb..fff2933b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -11,6 +11,12 @@ * it is not called during ZNC startup any more * Fix build on Solaris 10 * Fix build with LibreSSL +* Added two network-specific config options to control TLS certificate + validation + * `TrustAllCerts`: Disables certificate validation. Will take precedence + over TrustPKI + * `TrustPKI`: Whether or not to trust PKI-valid Certificates. Setting this + to false will make znc trust only trusted certificates added by the user. diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index 055a0fd4..9bf1304c 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -266,6 +266,12 @@ class CIRCNetwork { m_uJoinDelay = uJoinDelay; } + void SetTrustAllCerts(const bool bTrustAll = false) { m_bTrustAllCerts = bTrustAll; } + bool GetTrustAllCerts() const { return m_bTrustAllCerts; } + + void SetTrustPKI(const bool bTrustPKI = true) { m_bTrustPKI = bTrustPKI; } + bool GetTrustPKI() const { return m_bTrustPKI; } + unsigned long long BytesRead() const { return m_uBytesRead; } unsigned long long BytesWritten() const { return m_uBytesWritten; } @@ -305,6 +311,8 @@ class CIRCNetwork { CString m_sChanPrefixes; bool m_bIRCConnectEnabled; + bool m_bTrustAllCerts; + bool m_bTrustPKI; CString m_sIRCServer; std::vector m_vServers; size_t m_uServerIdx; ///< Index in m_vServers of our current server + 1 diff --git a/include/znc/Socket.h b/include/znc/Socket.h index a1648ea1..eea0b4da 100644 --- a/include/znc/Socket.h +++ b/include/znc/Socket.h @@ -46,6 +46,12 @@ class CZNCSock : public Csock, public CCoreTranslationMixin { m_ssTrustedFingerprints = ssFPs; } + void SetTrustAllCerts(const bool bTrustAll = false) { m_bTrustAllCerts = bTrustAll; } + bool GetTrustAllCerts() const { return m_bTrustAllCerts; } + + void SetTrustPKI(const bool bTrustPKI = true) { m_bTrustPKI = bTrustPKI; } + bool GetTrustPKI() const { return m_bTrustPKI; } + void SetEncoding(const CString&); virtual CString GetRemoteIP() const { return Csock::GetRemoteIP(); } @@ -60,6 +66,8 @@ class CZNCSock : public Csock, public CCoreTranslationMixin { CString m_sHostToVerifySSL; SCString m_ssTrustedFingerprints; SCString m_ssCertVerificationErrors; + bool m_bTrustAllCerts; + bool m_bTrustPKI; }; enum EAddrType { ADDR_IPV4ONLY, ADDR_IPV6ONLY, ADDR_ALL }; diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index d5ba49d2..95c0bae0 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -132,6 +132,8 @@ class CAdminMod : public CModule { {"Encoding", str}, #endif {"QuitMsg", str}, + {"TrustAllCerts", boolean}, + {"TrustPKI", boolean}, }; PrintVarsHelp(sVarFilter, nvars, ARRAY_SIZE(nvars), "The following variables are available when using " @@ -520,6 +522,10 @@ class CAdminMod : public CModule { #endif } else if (sVar.Equals("quitmsg")) { PutModule("QuitMsg = " + pNetwork->GetQuitMsg()); + } else if (sVar.Equals("trustallcerts")) { + PutModule("TrustAllCerts = " + CString(pNetwork->GetTrustAllCerts())); + } else if (sVar.Equals("trustpki")) { + PutModule("TrustPKI = " + CString(pNetwork->GetTrustPKI())); } else { PutModule("Error: Unknown variable"); } @@ -596,6 +602,14 @@ class CAdminMod : public CModule { } else if (sVar.Equals("quitmsg")) { pNetwork->SetQuitMsg(sValue); PutModule("QuitMsg = " + pNetwork->GetQuitMsg()); + } else if (sVar.Equals("trustallcerts")) { + bool b = sValue.ToBool(); + pNetwork->SetTrustAllCerts(b); + PutModule("TrustAllCerts = " + CString(b)); + } else if (sVar.Equals("trustpki")) { + bool b = sValue.ToBool(); + pNetwork->SetTrustPKI(b); + PutModule("TrustPKI = " + CString(b)); } else { PutModule("Error: Unknown variable"); } diff --git a/modules/data/webadmin/tmpl/add_edit_network.tmpl b/modules/data/webadmin/tmpl/add_edit_network.tmpl index f821c322..c5af1634 100644 --- a/modules/data/webadmin/tmpl/add_edit_network.tmpl +++ b/modules/data/webadmin/tmpl/add_edit_network.tmpl @@ -73,6 +73,18 @@ +
+
+
checked="checked" /> +
+
+ +
+
+
checked="checked" /> +
+
+