ErrorDetail.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef _SQUID_SSL_ERROR_DETAIL_H
10 #define _SQUID_SSL_ERROR_DETAIL_H
11 
12 #include "err_detail_type.h"
13 #include "ErrorDetailManager.h"
14 #include "HttpRequest.h"
15 #include "security/forward.h"
16 
17 namespace Ssl
18 {
24 bool ParseErrorString(const char *name, Security::Errors &);
25 
27 Security::ErrorCode GetErrorCode(const char *name);
28 
31 const char *GetErrorName(Security::ErrorCode value, const bool prefixRawCode = false);
32 
34 const char *GetErrorDescr(Security::ErrorCode value);
35 
37 bool ErrorIsOptional(const char *name);
38 
44 {
45 public:
46  // if broken certificate is nil, the peer certificate is broken
47  ErrorDetail(Security::ErrorCode err_no, X509 *peer, X509 *broken, const char *aReason = NULL);
48  ErrorDetail(ErrorDetail const &);
49  const String &toString() const;
50  void useRequest(HttpRequest *aRequest) { if (aRequest != NULL) request = aRequest;}
52  const char *errorName() const {return err_code();}
56  void setLibError(unsigned long lib_err_no) {lib_error_no = lib_err_no;}
58  X509 *peerCert() { return peer_cert.get(); }
60  X509 *brokenCert() {return broken_cert.get(); }
61 private:
62  typedef const char * (ErrorDetail::*fmt_action_t)() const;
67  {
68  public:
69  const char *code;
71  };
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;
88  unsigned long lib_error_no;
94 };
95 
96 }//namespace Ssl
97 #endif
98 
int ErrorCode
Squid defined error code (<0), an error code returned by X.509 API, or SSL_ERROR_NONE.
Definition: forward.h:92
const char * notafter() const
Definition: ErrorDetail.cc:664
X509 * brokenCert()
peer or intermediate certificate that failed validation
Definition: ErrorDetail.h:60
fmt_action_t fmt_action
A pointer to the conversion method.
Definition: ErrorDetail.h:70
const char * ca_name() const
Definition: ErrorDetail.cc:633
const char * subject() const
Definition: ErrorDetail.cc:585
int convert(const char *code, const char **value) const
Definition: ErrorDetail.cc:730
const char * cn() const
Definition: ErrorDetail.cc:615
ErrorDetailEntry detailEntry
Definition: ErrorDetail.h:92
unsigned long lib_error_no
low-level error returned by OpenSSL ERR_get_error(3SSL)
Definition: ErrorDetail.h:88
X509 * peerCert()
the peer certificate
Definition: ErrorDetail.h:58
bool ParseErrorString(const char *name, Security::Errors &)
Definition: ErrorDetail.cc:504
void buildDetail() const
Definition: ErrorDetail.cc:751
const char * GetErrorDescr(Security::ErrorCode value)
A short description of the TLS error "value".
Definition: ErrorDetail.cc:565
#define NULL
Definition: types.h:166
unsigned char code
Definition: html_quote.c:20
Definition: Xaction.cc:47
const String & toString() const
An error detail string to embed in squid error pages.
Definition: ErrorDetail.cc:777
const char * code
The formatting code.
Definition: ErrorDetail.h:69
const char * err_code() const
Definition: ErrorDetail.cc:679
String errDetailStr
Caches the error detail message.
Definition: ErrorDetail.h:86
Security::ErrorCode GetErrorCode(const char *name)
The Security::ErrorCode code of the error described by "name".
Definition: ErrorDetail.cc:493
void useRequest(HttpRequest *aRequest)
Definition: ErrorDetail.h:50
const char * notbefore() const
Definition: ErrorDetail.cc:649
Security::CertPointer broken_cert
A pointer to the broken certificate (peer or intermediate)
Definition: ErrorDetail.h:90
Security::CertPointer peer_cert
A pointer to the peer certificate.
Definition: ErrorDetail.h:89
const typedef char *(ErrorDetail::* fmt_action_t)() const
Definition: ErrorDetail.h:62
Security::ErrorCode error_no
The error code.
Definition: ErrorDetail.h:87
ErrorDetail(Security::ErrorCode err_no, X509 *peer, X509 *broken, const char *aReason=NULL)
Definition: ErrorDetail.cc:784
String errReason
A custom reason for error, else retrieved from OpenSSL.
Definition: ErrorDetail.h:91
Security::ErrorCode errorNo() const
The error no.
Definition: ErrorDetail.h:54
std::unordered_set< Security::ErrorCode > Errors
Definition: forward.h:109
const char * errorName() const
The error name to embed in squid error pages.
Definition: ErrorDetail.h:52
bool ErrorIsOptional(const char *name)
Definition: ErrorDetail.cc:555
const char * err_lib_error() const
Definition: ErrorDetail.cc:703
static err_frm_code ErrorFormatingCodes[]
The supported formatting codes.
Definition: ErrorDetail.h:72
void setLibError(unsigned long lib_err_no)
Sets the low-level error returned by OpenSSL ERR_get_error()
Definition: ErrorDetail.h:56
const char * err_descr() const
Definition: ErrorDetail.cc:694
HttpRequest::Pointer request
Definition: ErrorDetail.h:93
const char * GetErrorName(Security::ErrorCode value, const bool prefixRawCode=false)
Definition: ErrorDetail.cc:540
T * get() const
Returns raw and possibly nullptr pointer.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors