The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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: 1e608973084aee48e021f00e0becc005fc3c5869 $
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: 1e608973084aee48e021f00e0becc005fc3c5869 $")
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
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  * @param[in] _marker The certificate to emit a marker for.
44  */
45 #define fr_tls_strerror_push_chain(_chain, _leaf) \
46  _fr_tls_strerror_push_chain( __FILE__, __LINE__, _chain, _leaf)
47 void _fr_tls_strerror_push_chain(char const *file, int line, STACK_OF(X509) *chain, X509 *cert);
48 
49 /** Push a representation of a certificate chain with a marker onto the thread local error stack
50  *
51  * @param[in] _chain A stack of X509 certificates representing the chain.
52  * @param[in] _leaf The leaf certificate. May be NULL.
53  * @param[in] _marker The certificate to emit a marker for.
54  */
55 #define fr_tls_strerror_push_chain_marker(_chain, _leaf, _marker) \
56  _fr_tls_strerror_push_chain( __FILE__, __LINE__, _chain, _leaf, _marker)
57 void _fr_tls_strerror_push_chain_marker(char const *file, int line,
58  STACK_OF(X509) *chain, X509 *cert, X509 *marker);
59 
60 /** Push a collection of X509 objects into the thread local error stack
61  *
62  * @param[in] _objects to push onto the thread local error stack
63  */
64 #define fr_tls_strerror_push_x509_objects(_objects) \
65  _fr_tls_strerror_push_x509_objects( __FILE__, __LINE__, _objects)
66 void _fr_tls_strerror_push_x509_objects(char const *file, int line,
67  STACK_OF(X509_OBJECT) *objects);
68 
69 #define fr_tls_strerror_vprintf(_msg, _ap) \
70  _fr_tls_strerror_vprintf(__FILE__, __LINE__, _msg, _ap)
71 int _fr_tls_strerror_vprintf(char const *file, int line, char const *msg, va_list ap);
72 
73 /** Wrapper around fr_strerror_printf to log error messages for library functions calling libssl
74  *
75  * @param[in] msg Error message describing the operation being attempted.
76  * @param[in] ... Arguments for msg.
77  * @return the number of errors drained from the stack.
78  */
79 #define fr_tls_strerror_printf(_msg, ...) \
80  _fr_tls_strerror_printf(__FILE__, __LINE__, _msg, ##__VA_ARGS__)
81 
82 static inline CC_HINT(format (printf, 3, 4))
83 int _fr_tls_strerror_printf(char const *file, int line, char const *msg, ...)
84 {
85  va_list ap;
86  int ret;
87 
88  va_start(ap, msg);
89  ret = _fr_tls_strerror_vprintf(file, line, msg, ap);
90  va_end(ap);
91 
92  return ret;
93 }
94 
95 int fr_tls_strerror_drain(void);
96 #ifdef __cplusplus
97 }
98 #endif
99 #endif /* WITH_TLS */
int const char * file
Definition: acutest.h:702
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:482
int format(printf, 5, 0))