1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __TRANSPORT_H__
15 #define __TRANSPORT_H__
20 /** ssl_cert is a class which abstracts SSL certificate
21 * and key information.
23 * Because gnutls and openssl represent key information in
24 * wildly different ways, this class allows it to be accessed
25 * in a unified manner. These classes are attached to ssl-
26 * connected local users using Extensible::Extend() and the
35 std::string fingerprint;
36 bool trusted, invalid, unknownsigner, revoked;
38 /** Get certificate distinguished name
39 * @return Certificate DN
41 const std::string& GetDN()
46 /** Get Certificate issuer
47 * @return Certificate issuer
49 const std::string& GetIssuer()
54 /** Get error string if an error has occured
55 * @return The error associated with this users certificate,
56 * or an empty string if there is no error.
58 const std::string& GetError()
63 /** Get key fingerprint.
64 * @return The key fingerprint as a hex string.
66 const std::string& GetFingerprint()
72 * @return True if this is a trusted certificate
73 * (the certificate chain validates)
80 /** Get validity status
81 * @return True if the certificate itself is
90 * @return True if the certificate appears to be
93 bool IsUnknownSigner()
98 /** Get revokation status.
99 * @return True if the certificate is revoked.
100 * Note that this only works properly for GnuTLS
108 std::string GetMetaLine()
110 std::stringstream value;
111 bool hasError = error.length();
112 value << (IsInvalid() ? "v" : "V") << (IsTrusted() ? "T" : "t") << (IsRevoked() ? "R" : "r")
113 << (IsUnknownSigner() ? "s" : "S") << (hasError ? "E" : "e") << " ";
117 value << GetFingerprint() << " " << GetDN() << " " << GetIssuer();
122 /** Used to represent a request to a transport provider module
124 class ISHRequest : public Request
127 BufferedSocket* Sock;
129 ISHRequest(Module* Me, Module* Target, const char* rtype, BufferedSocket* sock) : Request(Me, Target, rtype), Sock(sock)
134 /** Used to represent a request to attach a cert to an BufferedSocket
136 class BufferedSocketAttachCertRequest : public ISHRequest
139 /** Initialize the request as an attach cert message */
140 BufferedSocketAttachCertRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_ATTACH", is)
145 /** Used to check if a handshake is complete on an BufferedSocket yet
147 class BufferedSocketHSCompleteRequest : public ISHRequest
150 /** Initialize the request as a 'handshake complete?' message */
151 BufferedSocketHSCompleteRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HSDONE", is)
156 /** Used to hook a transport provider to an BufferedSocket
158 class BufferedSocketHookRequest : public ISHRequest
161 /** Initialize request as a hook message */
162 BufferedSocketHookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HOOK", is)
167 /** Used to unhook a transport provider from an BufferedSocket
169 class BufferedSocketUnhookRequest : public ISHRequest
172 /** Initialize request as an unhook message */
173 BufferedSocketUnhookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_UNHOOK", is)
178 class BufferedSocketNameRequest : public ISHRequest
181 /** Initialize request as a get name message */
182 BufferedSocketNameRequest(Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_NAME", NULL)
187 class BufferedSocketFingerprintRequest : public ISHRequest
190 /** Initialize request as a fingerprint message */
191 BufferedSocketFingerprintRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "GET_FP", is)