| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "OSSL_CMP_LOG_OPEN 3SSL" |
| 58 |
.TH OSSL_CMP_LOG_OPEN 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
OSSL_CMP_log_open, |
| 65 |
OSSL_CMP_log_close, |
| 66 |
OSSL_CMP_severity, |
| 67 |
OSSL_CMP_LOG_EMERG, |
| 68 |
OSSL_CMP_LOG_ALERT, |
| 69 |
OSSL_CMP_LOG_CRIT, |
| 70 |
OSSL_CMP_LOG_ERR, |
| 71 |
OSSL_CMP_LOG_WARNING, |
| 72 |
OSSL_CMP_LOG_NOTICE, |
| 73 |
OSSL_CMP_LOG_INFO, |
| 74 |
OSSL_CMP_LOG_DEBUG, |
| 75 |
OSSL_CMP_LOG_TRACE, |
| 76 |
.PP |
| 77 |
OSSL_CMP_log_cb_t, |
| 78 |
OSSL_CMP_print_to_bio, |
| 79 |
OSSL_CMP_print_errors_cb |
| 80 |
\&\- functions for logging and error reporting |
| 81 |
.SH SYNOPSIS |
| 82 |
.IX Header "SYNOPSIS" |
| 83 |
.Vb 1 |
| 84 |
\& #include <openssl/cmp_util.h> |
| 85 |
\& |
| 86 |
\& int OSSL_CMP_log_open(void); |
| 87 |
\& void OSSL_CMP_log_close(void); |
| 88 |
\& |
| 89 |
\& /* severity level declarations resemble those from syslog.h */ |
| 90 |
\& typedef int OSSL_CMP_severity; |
| 91 |
\& #define OSSL_CMP_LOG_EMERG 0 |
| 92 |
\& #define OSSL_CMP_LOG_ALERT 1 |
| 93 |
\& #define OSSL_CMP_LOG_CRIT 2 |
| 94 |
\& #define OSSL_CMP_LOG_ERR 3 |
| 95 |
\& #define OSSL_CMP_LOG_WARNING 4 |
| 96 |
\& #define OSSL_CMP_LOG_NOTICE 5 |
| 97 |
\& #define OSSL_CMP_LOG_INFO 6 |
| 98 |
\& #define OSSL_CMP_LOG_DEBUG 7 |
| 99 |
\& #define OSSL_CMP_LOG_TRACE 8 |
| 100 |
\& |
| 101 |
\& typedef int (*OSSL_CMP_log_cb_t)(const char *component, |
| 102 |
\& const char *file, int line, |
| 103 |
\& OSSL_CMP_severity level, const char *msg); |
| 104 |
\& int OSSL_CMP_print_to_bio(BIO *bio, const char *component, const char *file, |
| 105 |
\& int line, OSSL_CMP_severity level, const char *msg); |
| 106 |
\& void OSSL_CMP_print_errors_cb(OSSL_CMP_log_cb_t log_fn); |
| 107 |
.Ve |
| 108 |
.SH DESCRIPTION |
| 109 |
.IX Header "DESCRIPTION" |
| 110 |
The logging and error reporting facility described here contains |
| 111 |
convenience functions for CMP-specific logging, |
| 112 |
including a string prefix mirroring the severity levels of syslog.h, |
| 113 |
and enhancements of the error queue mechanism needed for large diagnostic |
| 114 |
messages produced by the CMP library in case of certificate validation failures. |
| 115 |
.PP |
| 116 |
When an interesting activity is performed or an error occurs, some detail |
| 117 |
should be provided for user information, debugging, and auditing purposes. |
| 118 |
A CMP application can obtain this information by providing a callback function |
| 119 |
with the following type: |
| 120 |
.PP |
| 121 |
.Vb 3 |
| 122 |
\& typedef int (*OSSL_CMP_log_cb_t)(const char *component, |
| 123 |
\& const char *file, int line, |
| 124 |
\& OSSL_CMP_severity level, const char *msg); |
| 125 |
.Ve |
| 126 |
.PP |
| 127 |
The parameters may provide |
| 128 |
some component info (which may be a module name and/or function name) or NULL, |
| 129 |
a file pathname or NULL, |
| 130 |
a line number or 0 indicating the source code location, |
| 131 |
a severity level, and |
| 132 |
a message string describing the nature of the event, terminated by '\en'. |
| 133 |
.PP |
| 134 |
Even when an activity is successful some warnings may be useful and some degree |
| 135 |
of auditing may be required. Therefore, the logging facility supports a severity |
| 136 |
level and the callback function has a \fIlevel\fR parameter indicating such a |
| 137 |
level, such that error, warning, info, debug, etc. can be treated differently. |
| 138 |
The callback is activated only when the severity level is sufficient according |
| 139 |
to the current level of verbosity, which by default is \fBOSSL_CMP_LOG_INFO\fR. |
| 140 |
.PP |
| 141 |
The callback function may itself do non-trivial tasks like writing to |
| 142 |
a log file or remote stream, which in turn may fail. |
| 143 |
Therefore, the function should return 1 on success and 0 on failure. |
| 144 |
.PP |
| 145 |
\&\fBOSSL_CMP_log_open()\fR initializes the CMP-specific logging facility to output |
| 146 |
everything to STDOUT. It fails if the integrated tracing is disabled or STDIO |
| 147 |
is not available. It may be called during application startup. |
| 148 |
Alternatively, \fBOSSL_CMP_CTX_set_log_cb\fR\|(3) can be used for more flexibility. |
| 149 |
As long as neither if the two is used any logging output is ignored. |
| 150 |
.PP |
| 151 |
\&\fBOSSL_CMP_log_close()\fR may be called when all activities are finished to flush |
| 152 |
any pending CMP-specific log output and deallocate related resources. |
| 153 |
It may be called multiple times. It does get called at OpenSSL shutdown. |
| 154 |
.PP |
| 155 |
\&\fBOSSL_CMP_print_to_bio()\fR prints the given component info, filename, line number, |
| 156 |
severity level, and log message or error queue message to the given \fIbio\fR. |
| 157 |
\&\fIcomponent\fR usually is a function or module name. |
| 158 |
If it is NULL, empty, or "(unknown function)" then "CMP" is used as fallback. |
| 159 |
.PP |
| 160 |
\&\fBOSSL_CMP_print_errors_cb()\fR outputs any entries in the OpenSSL error queue. |
| 161 |
It is similar to \fBERR_print_errors_cb\fR\|(3) but uses the CMP log callback |
| 162 |
function \fIlog_fn\fR for uniformity with CMP logging if not NULL. Otherwise it |
| 163 |
prints to STDERR using \fBOSSL_CMP_print_to_bio\fR\|(3) (unless \fBOPENSSL_NO_STDIO\fR |
| 164 |
is defined). |
| 165 |
.SH "RETURN VALUES" |
| 166 |
.IX Header "RETURN VALUES" |
| 167 |
\&\fBOSSL_CMP_log_close()\fR and \fBOSSL_CMP_print_errors_cb()\fR do not return anything. |
| 168 |
.PP |
| 169 |
All other functions return 1 on success, 0 on error. |
| 170 |
.SH HISTORY |
| 171 |
.IX Header "HISTORY" |
| 172 |
The OpenSSL CMP support was added in OpenSSL 3.0. |
| 173 |
.SH COPYRIGHT |
| 174 |
.IX Header "COPYRIGHT" |
| 175 |
Copyright 2007\-2022 The OpenSSL Project Authors. All Rights Reserved. |
| 176 |
.PP |
| 177 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 178 |
this file except in compliance with the License. You can obtain a copy |
| 179 |
in the file LICENSE in the source distribution or at |
| 180 |
<https://www.openssl.org/source/license.html>. |