+ const SSLIOHook* const ssliohook = SSLIOHook::IsSSL(&localuser->eh);
+ if (!ssliohook)
+ return;
+
+ ssl_cert* const cert = ssliohook->GetCertificate();
+
+ {
+ std::string text = "*** You are connected to ";
+ if (!ssliohook->GetServerName(text))
+ text.append(ServerInstance->Config->ServerName);
+ text.append(" using SSL cipher '");
+ ssliohook->GetCiphersuite(text);
+ text.push_back('\'');
+ if ((cert) && (!cert->GetFingerprint().empty()))
+ text.append(" and your SSL certificate fingerprint is ").append(cert->GetFingerprint());
+ user->WriteNotice(text);
+ }
+
+ if (!cert)
+ return;
+ // find an auto-oper block for this user
+ for (ServerConfig::OperIndex::const_iterator i = ServerInstance->Config->oper_blocks.begin(); i != ServerInstance->Config->oper_blocks.end(); ++i)
+ {
+ OperInfo* ifo = i->second;
+ std::string fp = ifo->oper_block->getString("fingerprint");
+ if (fp == cert->fingerprint && ifo->oper_block->getBool("autologin"))
+ user->Oper(ifo);
+ }
+ }
+
+ ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass) CXX11_OVERRIDE
+ {
+ ssl_cert* cert = SSLClientCert::GetCertificate(&user->eh);
+ bool ok = true;
+ if (myclass->config->getString("requiressl") == "trusted")
+ {
+ ok = (cert && cert->IsCAVerified());
+ ServerInstance->Logs->Log("CONNECTCLASS", LOG_DEBUG, "Class requires a trusted SSL cert. Client %s one.", (ok ? "has" : "does not have"));
+ }
+ else if (myclass->config->getBool("requiressl"))
+ {
+ ok = (cert != NULL);
+ ServerInstance->Logs->Log("CONNECTCLASS", LOG_DEBUG, "Class requires any SSL cert. Client %s one.", (ok ? "has" : "does not have"));
+ }
+
+ if (!ok)
+ return MOD_RES_DENY;
+ return MOD_RES_PASSTHRU;
+ }