mirror of
https://github.com/znc/znc.git
synced 2026-08-08 09:52:55 +02:00
Merge pull request #1277 from xnrand/master
Add network-specific settings for cert validation
This commit is contained in:
@@ -140,6 +140,8 @@ CIRCNetwork::CIRCNetwork(CUser* pUser, const CString& sName)
|
||||
m_vQueries(),
|
||||
m_sChanPrefixes(""),
|
||||
m_bIRCConnectEnabled(true),
|
||||
m_bTrustAllCerts(false),
|
||||
m_bTrustPKI(true),
|
||||
m_sIRCServer(""),
|
||||
m_vServers(),
|
||||
m_uServerIdx(0),
|
||||
@@ -377,6 +379,8 @@ bool CIRCNetwork::ParseConfig(CConfig* pConfig, CString& sError,
|
||||
};
|
||||
TOption<bool> BoolOptions[] = {
|
||||
{"ircconnectenabled", &CIRCNetwork::SetIRCConnectEnabled},
|
||||
{"trustallcerts", &CIRCNetwork::SetTrustAllCerts},
|
||||
{"trustpki", &CIRCNetwork::SetTrustPKI},
|
||||
};
|
||||
TOption<double> DoubleOptions[] = {
|
||||
{"floodrate", &CIRCNetwork::SetFloodRate},
|
||||
@@ -545,6 +549,8 @@ CConfig CIRCNetwork::ToConfig() const {
|
||||
|
||||
config.AddKeyValuePair("IRCConnectEnabled",
|
||||
CString(GetIRCConnectEnabled()));
|
||||
config.AddKeyValuePair("TrustAllCerts", CString(GetTrustAllCerts()));
|
||||
config.AddKeyValuePair("TrustPKI", CString(GetTrustPKI()));
|
||||
config.AddKeyValuePair("FloodRate", CString(GetFloodRate()));
|
||||
config.AddKeyValuePair("FloodBurst", CString(GetFloodBurst()));
|
||||
config.AddKeyValuePair("JoinDelay", CString(GetJoinDelay()));
|
||||
@@ -1272,6 +1278,8 @@ bool CIRCNetwork::Connect() {
|
||||
CIRCSock* pIRCSock = new CIRCSock(this);
|
||||
pIRCSock->SetPass(pServer->GetPass());
|
||||
pIRCSock->SetSSLTrustedPeerFingerprints(m_ssTrustedFingerprints);
|
||||
pIRCSock->SetTrustAllCerts(GetTrustAllCerts());
|
||||
pIRCSock->SetTrustPKI(GetTrustPKI());
|
||||
|
||||
DEBUG("Connecting user/network [" << m_pUser->GetUserName() << "/"
|
||||
<< m_sName << "]");
|
||||
|
||||
+6
-2
@@ -122,13 +122,17 @@ void CZNCSock::SSLHandShakeFinished() {
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
if (GetTrustAllCerts()) {
|
||||
DEBUG(GetSockName() + ": Verification disabled, trusting all.");
|
||||
return;
|
||||
}
|
||||
CString sHostVerifyError;
|
||||
if (!ZNC_SSLVerifyHost(m_sHostToVerifySSL, pCert, sHostVerifyError)) {
|
||||
m_ssCertVerificationErrors.insert(sHostVerifyError);
|
||||
}
|
||||
X509_free(pCert);
|
||||
if (m_ssCertVerificationErrors.empty()) {
|
||||
DEBUG(GetSockName() + ": Good cert");
|
||||
if (GetTrustPKI() && m_ssCertVerificationErrors.empty()) {
|
||||
DEBUG(GetSockName() + ": Good cert (PKI valid)");
|
||||
return;
|
||||
}
|
||||
CString sFP = GetSSLPeerFingerprint();
|
||||
|
||||
Reference in New Issue
Block a user