/src/freeradius-server/src/freeradius-devel/tls/strerror.h
Line | Count | Source |
1 | | #pragma once |
2 | | /* |
3 | | * This program is free software; you can redistribute it and/or modify |
4 | | * it under the terms of the GNU General Public License as published by |
5 | | * the Free Software Foundation; either version 2 of the License, or |
6 | | * (at your option) any later version. |
7 | | * |
8 | | * This program is distributed in the hope that it will be useful, |
9 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | | * GNU General Public License for more details. |
12 | | * |
13 | | * You should have received a copy of the GNU General Public License |
14 | | * along with this program; if not, write to the Free Software |
15 | | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
16 | | */ |
17 | | #ifdef WITH_TLS |
18 | | /** |
19 | | * $Id: 4980068469f544cc9cdeea955289f0419bdf14e5 $ |
20 | | * |
21 | | * @file lib/tls/strerror.h |
22 | | * @brief Prototypes for TLS strerror |
23 | | * |
24 | | * @copyright 2022 Arran Cudbard-Bell (a.cudbardb@freeradius.org) |
25 | | */ |
26 | | RCSIDH(tls_strerror_h, "$Id: 4980068469f544cc9cdeea955289f0419bdf14e5 $") |
27 | | |
28 | | #include "openssl_user_macros.h" |
29 | | |
30 | | #include <openssl/x509.h> |
31 | | #include <stdint.h> |
32 | | |
33 | | #include <freeradius-devel/tls/base.h> |
34 | | |
35 | | #ifdef __cplusplus |
36 | | extern "C" { |
37 | | #endif |
38 | | |
39 | | /** Push a representation of a certificate chain onto the thread local error stack |
40 | | * |
41 | | * @param[in] _chain A stack of X509 certificates representing the chain. |
42 | | * @param[in] _leaf The leaf certificate. May be NULL. |
43 | | */ |
44 | | #define fr_tls_strerror_push_chain(_chain, _leaf) \ |
45 | | _fr_tls_strerror_push_chain( __FILE__, __LINE__, _chain, _leaf) |
46 | | void _fr_tls_strerror_push_chain(char const *file, int line, STACK_OF(X509) *chain, X509 *cert); |
47 | | |
48 | | /** Push a representation of a certificate chain with a marker onto the thread local error stack |
49 | | * |
50 | | * @param[in] _chain A stack of X509 certificates representing the chain. |
51 | | * @param[in] _leaf The leaf certificate. May be NULL. |
52 | | * @param[in] _marker The certificate to emit a marker for. |
53 | | */ |
54 | | #define fr_tls_strerror_push_chain_marker(_chain, _leaf, _marker) \ |
55 | | _fr_tls_strerror_push_chain_marker( __FILE__, __LINE__, _chain, _leaf, _marker) |
56 | | void _fr_tls_strerror_push_chain_marker(char const *file, int line, |
57 | | STACK_OF(X509) *chain, X509 *cert, X509 *marker); |
58 | | |
59 | | /** Push a collection of X509 objects into the thread local error stack |
60 | | * |
61 | | * @param[in] _objects to push onto the thread local error stack |
62 | | */ |
63 | | #define fr_tls_strerror_push_x509_objects(_objects) \ |
64 | | _fr_tls_strerror_push_x509_objects( __FILE__, __LINE__, _objects) |
65 | | void _fr_tls_strerror_push_x509_objects(char const *file, int line, |
66 | | STACK_OF(X509_OBJECT) *objects); |
67 | | |
68 | | #define fr_tls_strerror_vprintf(_msg, _ap) \ |
69 | 0 | _fr_tls_strerror_vprintf(__FILE__, __LINE__, _msg, _ap) |
70 | | int _fr_tls_strerror_vprintf(char const *file, int line, char const *msg, va_list ap); |
71 | | |
72 | | /** Wrapper around fr_strerror_printf to log error messages for library functions calling libssl |
73 | | * |
74 | | * @param[in] msg Error message describing the operation being attempted. |
75 | | * @param[in] ... Arguments for msg. |
76 | | * @return the number of errors drained from the stack. |
77 | | */ |
78 | | #define fr_tls_strerror_printf(_msg, ...) \ |
79 | 0 | _fr_tls_strerror_printf(__FILE__, __LINE__, _msg, ##__VA_ARGS__) |
80 | | |
81 | | static inline CC_HINT(format (printf, 3, 4)) |
82 | | int _fr_tls_strerror_printf(char const *file, int line, char const *msg, ...) |
83 | 0 | { |
84 | 0 | va_list ap; |
85 | 0 | int ret; |
86 | |
|
87 | 0 | va_start(ap, msg); |
88 | 0 | ret = _fr_tls_strerror_vprintf(file, line, msg, ap); |
89 | 0 | va_end(ap); |
90 | |
|
91 | 0 | return ret; |
92 | 0 | } Unexecuted instantiation: ctx.c:_fr_tls_strerror_printf Unexecuted instantiation: log.c:_fr_tls_strerror_printf |
93 | | |
94 | | int fr_tls_strerror_drain(void); |
95 | | #ifdef __cplusplus |
96 | | } |
97 | | #endif |
98 | | #endif /* WITH_TLS */ |