]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ssl/cert_validate_message.h
Polished code. No runtime changes expected.
[thirdparty/squid.git] / src / ssl / cert_validate_message.h
CommitLineData
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
12namespace Ssl
13{
14
15
16class ValidateCertificate {
17public:
18 STACK_OF(X509) *peerCerts;
19 Errors *errors;
20 std::string domainName;
21 ValidateCertificate() : peerCerts(NULL), errors(NULL) {}
22};
23
24class ValidateCertificateResponse {
25public:
26 class ErrorItem{
27 public:
3a7d782f 28 ErrorItem(): id(0), error_no(SSL_ERROR_NONE), cert(NULL) {}
a1f04d64
AR
29 ErrorItem(const ErrorItem &);
30 ~ErrorItem();
31 ErrorItem & operator = (const ErrorItem &);
32 void setCert(X509 *);
33 void clear();
3a7d782f
CT
34 int id; ///< The id of the error
35 ssl_error_t error_no; ///< The SSL error code
36 std::string error_reason; ///< A string describing the error
37 X509 *cert; ///< The broken certificate
a1f04d64
AR
38 };
39
3a7d782f
CT
40 typedef std::vector<ErrorItem> Errors;
41
42 ValidateCertificateResponse() {}
43 /// Search in errors list for an error with id=errorId
44 /// If know found a new ErrorItem added with the given id;
45 ErrorItem &getError(int errorId);
46 Errors errors; ///< The list of parsed errors
47};
48
49class CertValidateMessage: public CrtdMessage {
50private:
a1f04d64
AR
51 class CertItem {
52 public:
53 std::string name;
54 X509 *cert;
55 CertItem(): cert(NULL) {}
56 CertItem(const CertItem &);
57 CertItem & operator = (const CertItem &);
58 ~CertItem();
59 void setCert(X509 *);
60 };
a1f04d64
AR
61public:
62 CertValidateMessage(): CrtdMessage() {}
63 void composeRequest(ValidateCertificate const &vcert);
77dce8a5 64 bool parseResponse(ValidateCertificateResponse &resp, STACK_OF(X509) *peerCerts, std::string &error);
3a7d782f 65 X509 *getCertByName(std::vector<CertItem> const &, std::string const & name); ///< search in a list of CertItems for a certificate
a1f04d64
AR
66
67 /// String code for "cert_validate" messages
68 static const std::string code_cert_validate;
69 /// Parameter name for passing intended domain name
70 static const std::string param_domain;
71 /// Parameter name for passing SSL errors
72 static const std::string param_error;
73 /// Parameter name for passing SSL certificates
74 static const std::string param_cert;
75 /// Parameter name for passing the major SSL error
76 static const std::string param_error_name;
77 /// Parameter name for passing the error reason
78 static const std::string param_error_reason;
79 /// Parameter name for passing the error cert ID
80 static const std::string param_error_cert;
81};
82
83}//namespace Ssl
84#endif // SQUID_SSL_CERT_VALIDATE_MESSAGE_H