]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ssl/ErrorDetail.h
Maintenance: automate header guards 2/3 (#1655)
[thirdparty/squid.git] / src / ssl / ErrorDetail.h
1 /*
2 * Copyright (C) 1996-2023 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_SRC_SSL_ERRORDETAIL_H
10 #define SQUID_SRC_SSL_ERRORDETAIL_H
11
12 #include "security/ErrorDetail.h"
13
14 #include <optional>
15
16 // TODO: Remove Security::X wrappers and move the remaining configurable error
17 // details (i.e. templates/error-details.txt) code to src/security/ErrorDetail.
18
19 namespace Ssl
20 {
21 /**
22 * Converts user-friendly error "name" into an Security::ErrorCode
23 * and adds it to the provided container (using emplace).
24 * This function can handle numeric error numbers as well as names.
25 */
26 bool ParseErrorString(const char *name, Security::Errors &);
27
28 /// The Security::ErrorCode code of the error described by "name".
29 inline Security::ErrorCode
30 GetErrorCode(const char *name)
31 {
32 return Security::ErrorCodeFromName(name);
33 }
34
35 /// \return string representation of a known TLS error (or a raw error code)
36 /// \param prefixRawCode whether to prefix raw codes with "SSL_ERR="
37 inline const char *
38 GetErrorName(const Security::ErrorCode code, const bool prefixRawCode = false)
39 {
40 return Security::ErrorNameFromCode(code, prefixRawCode);
41 }
42
43 /// a short description of the given TLS error known to Squid (or, if the error
44 /// is unknown, nothing)
45 std::optional<SBuf> GetErrorDescr(Security::ErrorCode);
46
47 /// \return true if the TLS error is optional and may not be supported by current squid version
48 bool ErrorIsOptional(const char *name);
49
50 }//namespace Ssl
51 #endif /* SQUID_SRC_SSL_ERRORDETAIL_H */
52