]>
Commit | Line | Data |
---|---|---|
4d16918e CT |
1 | #ifndef _SQUID_SSL_ERROR_DETAIL_H |
2 | #define _SQUID_SSL_ERROR_DETAIL_H | |
3 | ||
4 | #include "err_detail_type.h" | |
5 | #include "ssl/support.h" | |
6 | #include "ssl/gadgets.h" | |
7 | ||
8 | #if HAVE_OPENSSL_SSL_H | |
9 | #include <openssl/ssl.h> | |
10 | #endif | |
11 | ||
12 | // Custom SSL errors; assumes all official errors are positive | |
13 | #define SQUID_X509_V_ERR_DOMAIN_MISMATCH -1 | |
14 | // All SSL errors range: from smallest (negative) custom to largest SSL error | |
15 | #define SQUID_SSL_ERROR_MIN SQUID_X509_V_ERR_DOMAIN_MISMATCH | |
16 | #define SQUID_SSL_ERROR_MAX INT_MAX | |
17 | ||
e34763f4 | 18 | namespace Ssl |
4d16918e | 19 | { |
e34763f4 | 20 | /// Squid defined error code (<0), an error code returned by SSL X509 api, or SSL_ERROR_NONE |
461b9576 | 21 | typedef int ssl_error_t; |
4d16918e CT |
22 | |
23 | /** | |
24 | \ingroup ServerProtocolSSLAPI | |
461b9576 | 25 | * The ssl_error_t representation of the error described by "name". |
4d16918e | 26 | */ |
5e430bf3 | 27 | ssl_error_t ParseErrorString(const char *name); |
4d16918e CT |
28 | |
29 | /** | |
30 | \ingroup ServerProtocolSSLAPI | |
31 | * The string representation of the SSL error "value" | |
32 | */ | |
5e430bf3 | 33 | const char *GetErrorName(ssl_error_t value); |
4d16918e | 34 | |
cf09bec7 CT |
35 | /** |
36 | \ingroup ServerProtocolSSLAPI | |
37 | * A short description of the SSL error "value" | |
38 | */ | |
39 | const char *GetErrorDescr(ssl_error_t value); | |
40 | ||
4d16918e CT |
41 | /** |
42 | \ingroup ServerProtocolSSLAPI | |
43 | * Used to pass SSL error details to the error pages returned to the | |
44 | * end user. | |
45 | */ | |
e34763f4 A |
46 | class ErrorDetail |
47 | { | |
4d16918e | 48 | public: |
461b9576 | 49 | ErrorDetail(ssl_error_t err_no, X509 *cert); |
4d16918e CT |
50 | ErrorDetail(ErrorDetail const &); |
51 | const String &toString() const; ///< An error detail string to embed in squid error pages | |
e4a8468d CT |
52 | /// The error name to embed in squid error pages |
53 | const char *errorName() const {return err_code();} | |
4d16918e CT |
54 | |
55 | private: | |
56 | typedef const char * (ErrorDetail::*fmt_action_t)() const; | |
57 | /** | |
58 | * Holds a formating code and its conversion method | |
59 | */ | |
e34763f4 A |
60 | class err_frm_code |
61 | { | |
4d16918e CT |
62 | public: |
63 | const char *code; ///< The formating code | |
64 | fmt_action_t fmt_action; ///< A pointer to the conversion method | |
65 | }; | |
66 | static err_frm_code ErrorFormatingCodes[]; ///< The supported formating codes | |
67 | ||
68 | const char *subject() const; | |
69 | const char *ca_name() const; | |
70 | const char *cn() const; | |
71 | const char *notbefore() const; | |
72 | const char *notafter() const; | |
73 | const char *err_code() const; | |
cf09bec7 | 74 | const char *err_descr() const; |
4d16918e CT |
75 | |
76 | int convert(const char *code, const char **value) const; | |
77 | void buildDetail() const; | |
e34763f4 | 78 | |
4d16918e | 79 | mutable String errDetailStr; ///< Caches the error detail message |
461b9576 | 80 | ssl_error_t error_no; ///< The error code |
e34763f4 | 81 | X509_Pointer peer_cert; ///< A pointer to the peer certificate |
4d16918e CT |
82 | }; |
83 | ||
84 | }//namespace Ssl | |
85 | #endif |