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 * ---------------------------------------------------
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 struct SSLCertificateRequest : public Request
123 Extensible* const item;
125 SSLCertificateRequest(StreamSocket* ss, Module* Me)
126 : Request(Me, ss->GetIOHook(), "GET_CERT"), item(ss), cert(NULL)
131 std::string GetFingerprint()
134 return cert->GetFingerprint();
139 struct SSLCertSubmission : public Request
141 Extensible* const item;
142 ssl_cert* const cert;
143 SSLCertSubmission(Extensible* is, Module* Me, Module* Target, ssl_cert* Cert)
144 : Request(Me, Target, "SET_CERT"), item(is), cert(Cert)