]>
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" | |
02259ff8 CT |
5 | #include "HttpRequest.h" |
6 | #include "ErrorDetailManager.h" | |
4d16918e CT |
7 | #include "ssl/support.h" |
8 | #include "ssl/gadgets.h" | |
9 | ||
10 | #if HAVE_OPENSSL_SSL_H | |
11 | #include <openssl/ssl.h> | |
12 | #endif | |
13 | ||
e34763f4 | 14 | namespace Ssl |
4d16918e | 15 | { |
4d16918e | 16 | /** |
02259ff8 | 17 | \ingroup ServerProtocolSSLAPI |
461b9576 | 18 | * The ssl_error_t representation of the error described by "name". |
02259ff8 | 19 | * This function also parses numeric arguments. |
4d16918e | 20 | */ |
5e430bf3 | 21 | ssl_error_t ParseErrorString(const char *name); |
4d16918e | 22 | |
02259ff8 CT |
23 | /** |
24 | \ingroup ServerProtocolSSLAPI | |
25 | * The ssl_error_t code of the error described by "name". | |
26 | */ | |
27 | ssl_error_t GetErrorCode(const char *name); | |
28 | ||
4d16918e CT |
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 | |
1febfec5 | 52 | void useRequest(HttpRequest *aRequest) { if (aRequest != NULL) request = aRequest;} |
e4a8468d CT |
53 | /// The error name to embed in squid error pages |
54 | const char *errorName() const {return err_code();} | |
8e9bae99 CT |
55 | ///Sets the low-level error returned by OpenSSL ERR_get_error() |
56 | void setLibError(unsigned long lib_err_no) {lib_error_no = lib_err_no;} | |
4d16918e CT |
57 | |
58 | private: | |
59 | typedef const char * (ErrorDetail::*fmt_action_t)() const; | |
60 | /** | |
61 | * Holds a formating code and its conversion method | |
62 | */ | |
e34763f4 A |
63 | class err_frm_code |
64 | { | |
4d16918e CT |
65 | public: |
66 | const char *code; ///< The formating code | |
67 | fmt_action_t fmt_action; ///< A pointer to the conversion method | |
68 | }; | |
69 | static err_frm_code ErrorFormatingCodes[]; ///< The supported formating codes | |
70 | ||
71 | const char *subject() const; | |
72 | const char *ca_name() const; | |
73 | const char *cn() const; | |
74 | const char *notbefore() const; | |
75 | const char *notafter() const; | |
76 | const char *err_code() const; | |
cf09bec7 | 77 | const char *err_descr() const; |
8e9bae99 | 78 | const char *err_lib_error() const; |
4d16918e CT |
79 | |
80 | int convert(const char *code, const char **value) const; | |
81 | void buildDetail() const; | |
e34763f4 | 82 | |
4d16918e | 83 | mutable String errDetailStr; ///< Caches the error detail message |
461b9576 | 84 | ssl_error_t error_no; ///< The error code |
8e9bae99 | 85 | unsigned long lib_error_no; ///< low-level error returned by OpenSSL ERR_get_error(3SSL) |
e34763f4 | 86 | X509_Pointer peer_cert; ///< A pointer to the peer certificate |
02259ff8 CT |
87 | mutable ErrorDetailEntry detailEntry; |
88 | HttpRequest::Pointer request; | |
4d16918e CT |
89 | }; |
90 | ||
91 | }//namespace Ssl | |
92 | #endif |