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

View File

@@ -937,6 +937,8 @@ class CWebAdminMod : public CModule {
Tmpl["IRCConnectEnabled"] =
CString(pNetwork->GetIRCConnectEnabled());
Tmpl["TrustAllCerts"] = CString(pNetwork->GetTrustAllCerts());
Tmpl["TrustPKI"] = CString(pNetwork->GetTrustPKI());
breadNet["Text"] = f("Edit Network [{1}]")(pNetwork->GetName());
@@ -985,6 +987,8 @@ class CWebAdminMod : public CModule {
Tmpl["Title"] =
f("Add Network for User [{1}]")(pUser->GetUserName());
Tmpl["IRCConnectEnabled"] = "true";
Tmpl["TrustAllCerts"] = "false";
Tmpl["TrustPKI"] = "true";
Tmpl["FloodProtection"] = "true";
Tmpl["FloodRate"] = "1.0";
Tmpl["FloodBurst"] = "4";
@@ -1076,6 +1080,9 @@ class CWebAdminMod : public CModule {
pNetwork->SetIRCConnectEnabled(WebSock.GetParam("doconnect").ToBool());
pNetwork->SetTrustAllCerts(WebSock.GetParam("trustallcerts").ToBool());
pNetwork->SetTrustPKI(WebSock.GetParam("trustpki").ToBool());
sArg = WebSock.GetParam("bindhost");
// To change BindHosts be admin or don't have DenySetBindHost
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetBindHost()) {