]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/ssl.h
Merge pull request #1157 from SaberUK/insp20+fix-cron-restart
[user/henk/code/inspircd.git] / src / modules / ssl.h
index a01d91430e84ef5d296c9d3741cc32f7c32e40e6..4c877551d61f59ab951042682a8f59e0c665f115 100644 (file)
@@ -1,18 +1,25 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __SSL_H__
-#define __SSL_H__
+
+#ifndef SSL_H
+#define SSL_H
 
 #include <map>
 #include <string>
@@ -34,6 +41,8 @@ class ssl_cert : public refcountbase
        std::string fingerprint;
        bool trusted, invalid, unknownsigner, revoked;
 
+       ssl_cert() : trusted(false), invalid(true), unknownsigner(true), revoked(false) {}
+
        /** Get certificate distinguished name
         * @return Certificate DN
         */
@@ -104,10 +113,15 @@ class ssl_cert : public refcountbase
                return revoked;
        }
 
+       bool IsCAVerified()
+       {
+               return trusted && !invalid && !revoked && !unknownsigner && error.empty();
+       }
+
        std::string GetMetaLine()
        {
                std::stringstream value;
-               bool hasError = error.length();
+               bool hasError = !error.empty();
                value << (IsInvalid() ? "v" : "V") << (IsTrusted() ? "T" : "t") << (IsRevoked() ? "R" : "r")
                        << (IsUnknownSigner() ? "s" : "S") << (hasError ? "E" : "e") << " ";
                if (hasError)
@@ -124,8 +138,8 @@ struct SocketCertificateRequest : public Request
        StreamSocket* const sock;
        ssl_cert* cert;
 
-       SocketCertificateRequest(StreamSocket* ss, Module* Me, Module* hook)
-               : Request(Me, hook, "GET_SSL_CERT"), sock(ss), cert(NULL)
+       SocketCertificateRequest(StreamSocket* ss, Module* Me)
+               : Request(Me, ss->GetIOHook(), "GET_SSL_CERT"), sock(ss), cert(NULL)
        {
                Send();
        }
@@ -158,12 +172,16 @@ struct UserCertificateRequest : public Request
        }
 };
 
-struct SSLCertSubmission : public Request
+class SSLRawSessionRequest : public Request
 {
-       Extensible* const item;
-       ssl_cert* const cert;
-       SSLCertSubmission(Extensible* is, Module* Me, Module* Target, ssl_cert* Cert)
-               : Request(Me, Target, "SET_CERT"), item(is), cert(Cert)
+ public:
+       const int fd;
+       void* data;
+
+       SSLRawSessionRequest(int FD, Module* srcmod, Module* destmod)
+               : Request(srcmod, destmod, "GET_RAW_SSL_SESSION")
+               , fd(FD)
+               , data(NULL)
        {
                Send();
        }