Add network-specific config for cert validation

Added the following two network-specific configuration options that can
be changed via controlpanel or webadmin:

* TrustAllCerts: Will trust ALL certificates when enabled, effectively
  disabling TLS certificate validation.
  Default value: false
* TrustPKI: Whether or not to trust PKI-valid certificates. Setting this
  to false will make znc trust only trusted certificates added by the
  user.
  Default value: true

With default values, behavior is exactly the same as before.

This is based on the work of Roelf Wichertjes. See YourBNC/znc@5c747598.

See znc/znc#866.
This commit is contained in:
xnrand
2016-05-20 01:17:26 +02:00
parent c5db7793d3
commit 409ed4b6bc
8 changed files with 69 additions and 2 deletions
+8
View File
@@ -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<CServer*> m_vServers;
size_t m_uServerIdx; ///< Index in m_vServers of our current server + 1
+8
View File
@@ -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 };