]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/OSSL_CMP_log_open.pod
Move EC_METHOD to internal-only
[thirdparty/openssl.git] / doc / man3 / OSSL_CMP_log_open.pod
CommitLineData
7960dbec
DDO
1=pod
2
3=head1 NAME
4
5OSSL_CMP_log_open,
6OSSL_CMP_log_close,
7960dbec
DDO
7OSSL_CMP_severity,
8OSSL_CMP_LOG_EMERG,
9OSSL_CMP_LOG_ALERT,
10OSSL_CMP_LOG_CRIT,
11OSSL_CMP_LOG_ERR,
12OSSL_CMP_LOG_WARNING,
13OSSL_CMP_LOG_NOTICE,
14OSSL_CMP_LOG_INFO,
15OSSL_CMP_LOG_DEBUG,
7e765f46 16OSSL_CMP_log_cb_t,
ebf30069 17OSSL_CMP_print_to_bio,
7960dbec
DDO
18OSSL_CMP_print_errors_cb
19- functions for logging and error reporting
20
21=head1 SYNOPSIS
22
23 #include <openssl/cmp_util.h>
24
25 int OSSL_CMP_log_open(void);
26 void OSSL_CMP_log_close(void);
7960dbec
DDO
27
28 /* severity level declarations resemble those from syslog.h */
29 typedef int OSSL_CMP_severity;
30 #define OSSL_CMP_LOG_EMERG 0
31 #define OSSL_CMP_LOG_ALERT 1
32 #define OSSL_CMP_LOG_CRIT 2
33 #define OSSL_CMP_LOG_ERR 3
34 #define OSSL_CMP_LOG_WARNING 4
35 #define OSSL_CMP_LOG_NOTICE 5
36 #define OSSL_CMP_LOG_INFO 6
37 #define OSSL_CMP_LOG_DEBUG 7
ebf30069 38
7e765f46 39 typedef int (*OSSL_CMP_log_cb_t)(const char *component,
652fba9e
DDO
40 const char *file, int line,
41 OSSL_CMP_severity level, const char *msg);
ebf30069
DDO
42 int OSSL_CMP_print_to_bio(BIO *bio, const char *component, const char *file,
43 int line, OSSL_CMP_severity level, const char *msg);
7e765f46 44 void OSSL_CMP_print_errors_cb(OSSL_CMP_log_cb_t log_fn);
7960dbec
DDO
45
46=head1 DESCRIPTION
47
48The logging and error reporting facility described here contains
ebf30069 49convenience functions for CMP-specific logging,
7960dbec
DDO
50including a string prefix mirroring the severity levels of syslog.h,
51and enhancements of the error queue mechanism needed for large diagnostic
52messages produced by the CMP library in case of certificate validation failures.
53
54When an interesting activity is performed or an error occurs, some detail
55should be provided for user information, debugging, and auditing purposes.
56A CMP application can obtain this information by providing a callback function
57with the following type:
58
7e765f46 59 typedef int (*OSSL_CMP_log_cb_t)(const char *component,
ebf30069
DDO
60 const char *file, int line,
61 OSSL_CMP_severity level, const char *msg);
7960dbec
DDO
62
63The parameters may provide
ebf30069 64some component info (which may be a module name and/or function name) or NULL,
9c0586d5 65a file pathname or NULL,
7960dbec
DDO
66a line number or 0 indicating the source code location,
67a severity level, and
68a message string describing the nature of the event, terminated by '\n'.
69
70Even when an activity is successful some warnings may be useful and some degree
71of auditing may be required. Therefore the logging facility supports a severity
72level and the callback function has a B<level> parameter indicating such a
73level, such that error, warning, info, debug, etc. can be treated differently.
74The callback is activated only when the severity level is sufficient according
75to the current level of verbosity, which by default is OSSL_CMP_LOG_INFO.
76
77The callback function may itself do non-trivial tasks like writing to
78a log file or remote stream, which in turn may fail.
79Therefore the function should return 1 on success and 0 on failure.
80
81OSSL_CMP_log_open() initializes the CMP-specific logging facility to output
82everything to STDOUT. It fails if the integrated tracing is disabled or STDIO
83is not available. It may be called during application startup.
84Alternatively, L<OSSL_CMP_CTX_set_log_cb(3)> can be used for more flexibility.
85As long as neither if the two is used any logging output is ignored.
86
87OSSL_CMP_log_close() may be called when all activities are finished to flush
88any pending CMP-specific log output and deallocate related resources.
89It may be called multiple times. It does get called at OpenSSL stutdown.
90
ebf30069
DDO
91OSSL_CMP_print_to_bio() prints the given component info, filename, line number,
92severity level, and log message or error queue message to the given B<bio>.
93B<component> usually is a function or module name.
94If it is NULL, empty, or "(unknown function)" then "CMP" is used as fallback.
7960dbec
DDO
95
96OSSL_CMP_print_errors_cb() outputs any entries in the OpenSSL error queue.
97It is similar to B<ERR_print_errors_cb()> but uses the CMP log callback function
ebf30069
DDO
98C<log_fn> for uniformity with CMP logging if not B<NULL>. Otherwise it prints to
99STDERR using B<OSSL_CMP_print_to_bio(3)> (unless OPENSSL_NO_STDIO is defined).
7960dbec
DDO
100
101=head1 RETURN VALUES
102
103OSSL_CMP_log_close() and OSSL_CMP_print_errors_cb() do not return anything.
104
105All other functions return 1 on success, 0 on error.
106
107=head1 HISTORY
108
109The OpenSSL CMP support was added in OpenSSL 3.0.
110
111=head1 COPYRIGHT
112
33388b44 113Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
7960dbec
DDO
114
115Licensed under the Apache License 2.0 (the "License"). You may not use
116this file except in compliance with the License. You can obtain a copy
117in the file LICENSE in the source distribution or at
118L<https://www.openssl.org/source/license.html>.
119
120=cut