]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ssl/ErrorDetail.h
Forward a StoreEntry holding the bumped secure connection establishment
[thirdparty/squid.git] / src / ssl / ErrorDetail.h
1 #ifndef _SQUID_SSL_ERROR_DETAIL_H
2 #define _SQUID_SSL_ERROR_DETAIL_H
3
4 #include "err_detail_type.h"
5 #include "HttpRequest.h"
6 #include "ErrorDetailManager.h"
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
14 namespace Ssl
15 {
16 /**
17 \ingroup ServerProtocolSSLAPI
18 * The ssl_error_t representation of the error described by "name".
19 * This function also parses numeric arguments.
20 */
21 ssl_error_t ParseErrorString(const char *name);
22
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
29 /**
30 \ingroup ServerProtocolSSLAPI
31 * The string representation of the SSL error "value"
32 */
33 const char *GetErrorName(ssl_error_t value);
34
35 /**
36 \ingroup ServerProtocolSSLAPI
37 * A short description of the SSL error "value"
38 */
39 const char *GetErrorDescr(ssl_error_t value);
40
41 /**
42 \ingroup ServerProtocolSSLAPI
43 * Used to pass SSL error details to the error pages returned to the
44 * end user.
45 */
46 class ErrorDetail
47 {
48 public:
49 ErrorDetail(ssl_error_t err_no, X509 *cert);
50 ErrorDetail(ErrorDetail const &);
51 const String &toString() const; ///< An error detail string to embed in squid error pages
52 void useRequest(HttpRequest *aRequest) { if (aRequest != NULL) request = aRequest;}
53 /// The error name to embed in squid error pages
54 const char *errorName() const {return err_code();}
55 /// The error no
56 ssl_error_t errorNo() const {return error_no;}
57 ///Sets the low-level error returned by OpenSSL ERR_get_error()
58 void setLibError(unsigned long lib_err_no) {lib_error_no = lib_err_no;}
59 ///The peer certificate
60 X509 *peerCert() { return peer_cert.get(); }
61 private:
62 typedef const char * (ErrorDetail::*fmt_action_t)() const;
63 /**
64 * Holds a formating code and its conversion method
65 */
66 class err_frm_code
67 {
68 public:
69 const char *code; ///< The formating code
70 fmt_action_t fmt_action; ///< A pointer to the conversion method
71 };
72 static err_frm_code ErrorFormatingCodes[]; ///< The supported formating codes
73
74 const char *subject() const;
75 const char *ca_name() const;
76 const char *cn() const;
77 const char *notbefore() const;
78 const char *notafter() const;
79 const char *err_code() const;
80 const char *err_descr() const;
81 const char *err_lib_error() const;
82
83 int convert(const char *code, const char **value) const;
84 void buildDetail() const;
85
86 mutable String errDetailStr; ///< Caches the error detail message
87 ssl_error_t error_no; ///< The error code
88 unsigned long lib_error_no; ///< low-level error returned by OpenSSL ERR_get_error(3SSL)
89 X509_Pointer peer_cert; ///< A pointer to the peer certificate
90 mutable ErrorDetailEntry detailEntry;
91 HttpRequest::Pointer request;
92 };
93
94 }//namespace Ssl
95 #endif