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 SSLCertExt
34 std::string fingerprint;
35 bool trusted, invalid, unknownsigner, revoked;
37 /** Get certificate distinguished name
38 * @return Certificate DN
40 const std::string& GetDN()
45 /** Get Certificate issuer
46 * @return Certificate issuer
48 const std::string& GetIssuer()
53 /** Get error string if an error has occured
54 * @return The error associated with this users certificate,
55 * or an empty string if there is no error.
57 const std::string& GetError()
62 /** Get key fingerprint.
63 * @return The key fingerprint as a hex string.
65 const std::string& GetFingerprint()
71 * @return True if this is a trusted certificate
72 * (the certificate chain validates)
79 /** Get validity status
80 * @return True if the certificate itself is
89 * @return True if the certificate appears to be
92 bool IsUnknownSigner()
97 /** Get revokation status.
98 * @return True if the certificate is revoked.
99 * Note that this only works properly for GnuTLS
107 std::string GetMetaLine()
109 std::stringstream value;
110 bool hasError = error.length();
111 value << (IsInvalid() ? "v" : "V") << (IsTrusted() ? "T" : "t") << (IsRevoked() ? "R" : "r")
112 << (IsUnknownSigner() ? "s" : "S") << (hasError ? "E" : "e") << " ";
116 value << GetFingerprint() << " " << GetDN() << " " << GetIssuer();
121 /** Used to represent a request to a transport provider module
123 class ISHRequest : public Request
126 BufferedSocket* Sock;
128 ISHRequest(Module* Me, Module* Target, const char* rtype, BufferedSocket* sock) : Request(Me, Target, rtype), Sock(sock)
133 /** Used to represent a request to attach a cert to an BufferedSocket
135 class BufferedSocketAttachCertRequest : public ISHRequest
138 /** Initialize the request as an attach cert message */
139 BufferedSocketAttachCertRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_ATTACH", is)
144 /** Used to check if a handshake is complete on an BufferedSocket yet
146 class BufferedSocketHSCompleteRequest : public ISHRequest
149 /** Initialize the request as a 'handshake complete?' message */
150 BufferedSocketHSCompleteRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HSDONE", is)
155 /** Used to hook a transport provider to an BufferedSocket
157 class BufferedSocketHookRequest : public ISHRequest
160 /** Initialize request as a hook message */
161 BufferedSocketHookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HOOK", is)
166 /** Used to unhook a transport provider from an BufferedSocket
168 class BufferedSocketUnhookRequest : public ISHRequest
171 /** Initialize request as an unhook message */
172 BufferedSocketUnhookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_UNHOOK", is)
177 class BufferedSocketNameRequest : public ISHRequest
180 /** Initialize request as a get name message */
181 BufferedSocketNameRequest(Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_NAME", NULL)
186 struct BufferedSocketCertificateRequest : public Request
188 Extensible* const item;
190 BufferedSocketCertificateRequest(Extensible* is, Module* Me, Module* Target)
191 : Request(Me, Target, "GET_CERT"), item(is), cert(NULL)
196 struct BufferedSocketFingerprintSubmission : public Request
198 Extensible* const item;
199 ssl_cert* const cert;
200 BufferedSocketFingerprintSubmission(Extensible* is, Module* Me, Module* Target, ssl_cert* Cert)
201 : Request(Me, Target, "SET_CERT"), item(is), cert(Cert)