The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
strerror.h
Go to the documentation of this file.
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: 6724f7dfbe1d07e8a212e74eb84e2c63fa234b76 $
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 */
26RCSIDH(tls_strerror_h, "$Id: 6724f7dfbe1d07e8a212e74eb84e2c63fa234b76 $")
27
28#include "openssl_user_macros.h"
29
30#include <openssl/x509.h>
31#include <stdint.h>
32
33#include "base.h"
34
35#ifdef __cplusplus
36extern "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)
46void _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)
56void _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)
65void _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 _fr_tls_strerror_vprintf(__FILE__, __LINE__, _msg, _ap)
70int _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 _fr_tls_strerror_printf(__FILE__, __LINE__, _msg, ##__VA_ARGS__)
80
81static inline CC_HINT(format (printf, 3, 4))
82int _fr_tls_strerror_printf(char const *file, int line, char const *msg, ...)
83{
84 va_list ap;
85 int ret;
86
87 va_start(ap, msg);
88 ret = _fr_tls_strerror_vprintf(file, line, msg, ap);
89 va_end(ap);
90
91 return ret;
92}
93
94int fr_tls_strerror_drain(void);
95#ifdef __cplusplus
96}
97#endif
98#endif /* WITH_TLS */
va_end(args)
log_entry msg
Definition acutest.h:794
int const char int line
Definition acutest.h:702
va_start(args, fmt)
#define RCSIDH(h, id)
Definition build.h:561