25 RCSID(
"$Id: 5f189df2904b282ad45cb6de014016551ebec279 $")
29 #define LOG_PREFIX "tls"
31 #include <freeradius-devel/util/debug.h>
32 #include <freeradius-devel/util/strerror.h>
40 static void _tls_cert_line_push(
char const *
file,
int line,
int idx, X509 *cert)
44 X509_NAME_oneline(X509_get_subject_name(cert), subject,
sizeof(subject));
45 subject[
sizeof(subject) - 1] =
'\0';
50 static void _tls_cert_line_marker_push(
char const *
file,
int line,
51 int idx, X509 *cert,
bool marker)
55 X509_NAME_oneline(X509_get_subject_name(cert), subject,
sizeof(subject));
56 subject[
sizeof(subject) - 1] =
'\0';
62 static void _tls_cert_line_marker_no_idx_push(
char const *
file,
int line, X509 *cert)
66 X509_NAME_oneline(X509_get_subject_name(cert), subject,
sizeof(subject));
67 subject[
sizeof(subject) - 1] =
'\0';
79 void _fr_tls_strerror_push_chain(
char const *
file,
int line, STACK_OF(X509) *chain, X509 *cert)
83 for (i = sk_X509_num(chain); i > 0 ; i--) {
84 _tls_cert_line_push(
file,
line, i, sk_X509_value(chain, i - 1));
86 if (cert) _tls_cert_line_push(
file,
line, i, cert);
97 void _fr_tls_strerror_push_chain_marker(
char const *
file,
int line,
98 STACK_OF(X509) *chain, X509 *cert, X509 *marker)
102 for (i = sk_X509_num(chain); i > 0 ; i--) {
103 X509 *selected = sk_X509_value(chain, i - 1);
104 _tls_cert_line_marker_push(
file,
line, i, selected, (selected == marker));
106 if (cert) _tls_cert_line_marker_push(
file,
line, i, cert, (cert == marker));
115 void _fr_tls_strerror_push_x509_objects(
char const *
file,
int line, STACK_OF(X509_OBJECT) *objects)
119 for (i = sk_X509_OBJECT_num(objects); i > 0 ; i--) {
120 X509_OBJECT *obj = sk_X509_OBJECT_value(objects, i - 1);
122 switch (X509_OBJECT_get_type(obj)) {
127 _tls_cert_line_marker_no_idx_push(
file,
line, X509_OBJECT_get0_X509(obj));
151 int _fr_tls_strerror_vprintf(
char const *
file,
int line,
char const *
msg, va_list ap)
159 char const *openssl_file;
169 error = ERR_get_error_all(&openssl_file, &openssl_line, &func, &
data, &flags);
170 if (!(flags & ERR_TXT_STRING))
data = NULL;
178 p = talloc_vasprintf(NULL,
msg, ap);
203 while ((error = ERR_get_error_all(&openssl_file, &openssl_line, &func, &
data, &flags))) {
204 if (!(flags & ERR_TXT_STRING))
data = NULL;
222 int fr_tls_strerror_drain(
void)
227 char const *openssl_file;
240 error = ERR_get_error_all(&openssl_file, &openssl_line, &func, &
data, &flags);
241 if (!error)
return 0;
242 if (!(flags & ERR_TXT_STRING))
data = NULL;
248 while ((error = ERR_get_error_all(&openssl_file, &openssl_line, &func, &
data, &flags))) {
249 if (!(flags & ERR_TXT_STRING))
continue;
static int const char char buffer[256]
#define USES_APPLE_DEPRECATED_API
#define DIAG_UNKNOWN_PRAGMAS
void _fr_strerror_vprintf(char const *file, int line, char const *fmt, va_list ap)
Log to thread local error buffer.
static void _fr_strerror_printf(char const *file, int line, char const *fmt,...)
static void _fr_strerror_printf_push(char const *file, int line, char const *fmt,...)
char const * fr_tls_utils_x509_pkey_type(X509 *cert)
Returns a friendly identifier for the public key type of a certificate.
int format(printf, 5, 0))