]>
Commit | Line | Data |
---|---|---|
a1f04d64 AR |
1 | /* |
2 | * $Id$ | |
3 | */ | |
4 | ||
5 | #ifndef SQUID_SSL_CERT_VALIDATE_MESSAGE_H | |
6 | #define SQUID_SSL_CERT_VALIDATE_MESSAGE_H | |
7 | ||
8 | #include "ssl/support.h" | |
9 | #include "ssl/crtd_message.h" | |
10 | #include <vector> | |
11 | ||
22636a68 | 12 | namespace Ssl |
a1f04d64 AR |
13 | { |
14 | ||
b56756cb CT |
15 | /** |
16 | * This class is used to hold the required informations to build | |
17 | * a request message for the certificate validator helper | |
18 | */ | |
22636a68 CT |
19 | class CertValidationRequest |
20 | { | |
a1f04d64 | 21 | public: |
b56756cb CT |
22 | STACK_OF(X509) *peerCerts; ///< The list of sent by SSL server |
23 | Errors *errors; ///< The list of errors detected | |
24 | std::string domainName; ///< The server name | |
25 | CertValidationRequest() : peerCerts(NULL), errors(NULL) {} | |
a1f04d64 AR |
26 | }; |
27 | ||
b56756cb CT |
28 | /** |
29 | * This class is used to store informations found in certificate validation | |
30 | * response messages read from certificate validator helper | |
31 | */ | |
22636a68 CT |
32 | class CertValidationResponse |
33 | { | |
a1f04d64 | 34 | public: |
b56756cb CT |
35 | /** |
36 | * This class used to hold error informations returned from | |
37 | * cert validator helper. | |
38 | */ | |
22636a68 CT |
39 | class RecvdError |
40 | { | |
a1f04d64 | 41 | public: |
b56756cb CT |
42 | RecvdError(): id(0), error_no(SSL_ERROR_NONE), cert(NULL) {} |
43 | RecvdError(const RecvdError &); | |
44 | ~RecvdError(); | |
45 | RecvdError & operator = (const RecvdError &); | |
46 | void setCert(X509 *); ///< Sets cert to the given certificate | |
3a7d782f | 47 | int id; ///< The id of the error |
b56756cb | 48 | ssl_error_t error_no; ///< The OpenSSL error code |
3a7d782f CT |
49 | std::string error_reason; ///< A string describing the error |
50 | X509 *cert; ///< The broken certificate | |
a1f04d64 AR |
51 | }; |
52 | ||
b56756cb | 53 | typedef std::vector<RecvdError> RecvdErrors; |
3a7d782f | 54 | |
b56756cb CT |
55 | /// Search in errors list for the error item with id=errorId. |
56 | /// If none found a new RecvdError item added with the given id; | |
57 | RecvdError &getError(int errorId); | |
58 | RecvdErrors errors; ///< The list of parsed errors | |
3a7d782f CT |
59 | }; |
60 | ||
b56756cb CT |
61 | /** |
62 | * This class is responsible for composing or parsing messages destined to | |
63 | * or comming from a cert validator helper. | |
64 | * The messages format is: | |
65 | * <response/request code> <whitespace> <body length> <whitespace> <key=value> ...\1 | |
66 | */ | |
22636a68 CT |
67 | class CertValidationMsg: public CrtdMessage |
68 | { | |
3a7d782f | 69 | private: |
b56756cb CT |
70 | /** |
71 | * This class used to hold the certId/cert pairs found | |
72 | * in cert validation messages. | |
73 | */ | |
22636a68 CT |
74 | class CertItem |
75 | { | |
a1f04d64 | 76 | public: |
b56756cb CT |
77 | std::string name; ///< The certificate Id to use |
78 | X509 *cert; ///< A pointer to certificate | |
a1f04d64 AR |
79 | CertItem(): cert(NULL) {} |
80 | CertItem(const CertItem &); | |
81 | CertItem & operator = (const CertItem &); | |
82 | ~CertItem(); | |
b56756cb | 83 | void setCert(X509 *); ///< Sets cert to the given certificate |
a1f04d64 | 84 | }; |
b56756cb | 85 | |
a1f04d64 | 86 | public: |
b56756cb CT |
87 | CertValidationMsg(): CrtdMessage() {} |
88 | ||
89 | /// Build a request message for the cert validation helper | |
90 | /// using informations provided by vcert object | |
91 | void composeRequest(CertValidationRequest const &vcert); | |
92 | ||
93 | /// Parse a response message and fill the resp object with parsed informations | |
94 | bool parseResponse(CertValidationResponse &resp, STACK_OF(X509) *peerCerts, std::string &error); | |
95 | ||
96 | /// Search a CertItems list for the certificate with ID "name" | |
97 | X509 *getCertByName(std::vector<CertItem> const &, std::string const & name); | |
a1f04d64 AR |
98 | |
99 | /// String code for "cert_validate" messages | |
100 | static const std::string code_cert_validate; | |
101 | /// Parameter name for passing intended domain name | |
102 | static const std::string param_domain; | |
103 | /// Parameter name for passing SSL errors | |
104 | static const std::string param_error; | |
105 | /// Parameter name for passing SSL certificates | |
22636a68 | 106 | static const std::string param_cert; |
a1f04d64 | 107 | /// Parameter name for passing the major SSL error |
22636a68 | 108 | static const std::string param_error_name; |
a1f04d64 | 109 | /// Parameter name for passing the error reason |
22636a68 | 110 | static const std::string param_error_reason; |
a1f04d64 AR |
111 | /// Parameter name for passing the error cert ID |
112 | static const std::string param_error_cert; | |
113 | }; | |
114 | ||
115 | }//namespace Ssl | |
116 | #endif // SQUID_SSL_CERT_VALIDATE_MESSAGE_H |