xref: /freebsd/secure/lib/libcrypto/man/man3/CONF_modules_load_file.3 (revision 7ef62cebc2f965b0f640263e179276928885e33d)
Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "CONF_MODULES_LOAD_FILE 3"
CONF_MODULES_LOAD_FILE 3 "2023-05-30" "3.0.9" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
CONF_get1_default_config_file, CONF_modules_load_file_ex, CONF_modules_load_file, CONF_modules_load \- OpenSSL configuration functions
"SYNOPSIS"
Header "SYNOPSIS" .Vb 1 #include <openssl/conf.h> \& char *CONF_get1_default_config_file(void); int CONF_modules_load_file_ex(OSSL_LIB_CTX *libctx, const char *filename, const char *appname, unsigned long flags); int CONF_modules_load_file(const char *filename, const char *appname, unsigned long flags); int CONF_modules_load(const CONF *cnf, const char *appname, unsigned long flags); .Ve
"DESCRIPTION"
Header "DESCRIPTION" The function CONF_get1_default_config_file() determines the default configuration file pathname as follows. If the \s-1OPENSSL_CONF\s0 environment variable is set its value is returned. Else the function returns the path obtained using \fBX509_get_default_cert_area\|(3) with the filename "openssl.cnf" appended. The caller is responsible for freeing any string returned.

The function CONF_modules_load_file_ex() configures OpenSSL using library context libctx file filename and application name appname. If filename is \s-1NULL\s0 the standard OpenSSL configuration file is used as determined by calling CONF_get1_default_config_file(). If appname is \s-1NULL\s0 the standard OpenSSL application name openssl_conf is used. The behaviour can be customized using flags. Note that, the error suppressing can be overriden by config_diagnostics as described in config\|(5).

\fBCONF_modules_load_file() is the same as CONF_modules_load_file_ex() but has a \s-1NULL\s0 library context.

\fBCONF_modules_load() is identical to CONF_modules_load_file() except it reads configuration information from cnf.

"NOTES"
Header "NOTES" The following flags are currently recognized:

If \s-1CONF_MFLAGS_IGNORE_ERRORS\s0 is set errors returned by individual configuration modules are ignored. If not set the first module error is considered fatal and no further modules are loaded.

Normally any modules errors will add error information to the error queue. If \fB\s-1CONF_MFLAGS_SILENT\s0 is set no error information is added.

If \s-1CONF_MFLAGS_IGNORE_RETURN_CODES\s0 is set the function unconditionally returns success. This is used by default in OPENSSL_init_crypto\|(3) to ignore any errors in the default system-wide configuration file, as having all OpenSSL applications fail to start when there are potentially minor issues in the file is too risky. Applications calling CONF_modules_load_file_ex explicitly should not generally set this flag.

If \s-1CONF_MFLAGS_NO_DSO\s0 is set configuration module loading from DSOs is disabled.

\fB\s-1CONF_MFLAGS_IGNORE_MISSING_FILE\s0 if set will make CONF_load_modules_file() ignore missing configuration files. Normally a missing configuration file return an error.

\fB\s-1CONF_MFLAGS_DEFAULT_SECTION\s0 if set and appname is not \s-1NULL\s0 will use the default section pointed to by openssl_conf if appname does not exist.

By using CONF_modules_load_file_ex() with appropriate flags an application can customise application configuration to best suit its needs. In some cases the use of a configuration file is optional and its absence is not an error: in this case \s-1CONF_MFLAGS_IGNORE_MISSING_FILE\s0 would be set.

Errors during configuration may also be handled differently by different applications. For example in some cases an error may simply print out a warning message and the application continue. In other cases an application might consider a configuration file error as fatal and exit immediately.

Applications can use the CONF_modules_load() function if they wish to load a configuration file themselves and have finer control over how errors are treated.

"RETURN VALUES"
Header "RETURN VALUES" These functions return 1 for success and a zero or negative value for failure. If module errors are not ignored the return code will reflect the return value of the failing module (this will always be zero or negative).
"EXAMPLES"
Header "EXAMPLES" Load a configuration file and print out any errors and exit (missing file considered fatal):

.Vb 5 if (CONF_modules_load_file_ex(libctx, NULL, NULL, 0) <= 0) { fprintf(stderr, "FATAL: error loading configuration file\en"); ERR_print_errors_fp(stderr); exit(1); } .Ve

Load default configuration file using the section indicated by \*(L"myapp\*(R", tolerate missing files, but exit on other errors:

.Vb 6 if (CONF_modules_load_file_ex(NULL, NULL, "myapp", CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) { fprintf(stderr, "FATAL: error loading configuration file\en"); ERR_print_errors_fp(stderr); exit(1); } .Ve

Load custom configuration file and section, only print warnings on error, missing configuration file ignored:

.Vb 5 if (CONF_modules_load_file_ex(NULL, "/something/app.cnf", "myapp", CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) { fprintf(stderr, "WARNING: error loading configuration file\en"); ERR_print_errors_fp(stderr); } .Ve

Load and parse configuration file manually, custom error handling:

.Vb 3 FILE *fp; CONF *cnf = NULL; long eline; \& fp = fopen("/somepath/app.cnf", "r"); if (fp == NULL) { fprintf(stderr, "Error opening configuration file\en"); /* Other missing configuration file behaviour */ } else { cnf = NCONF_new_ex(libctx, NULL); if (NCONF_load_fp(cnf, fp, &eline) == 0) { fprintf(stderr, "Error on line %ld of configuration file\en", eline); ERR_print_errors_fp(stderr); /* Other malformed configuration file behaviour */ } else if (CONF_modules_load(cnf, "appname", 0) <= 0) { fprintf(stderr, "Error configuring application\en"); ERR_print_errors_fp(stderr); /* Other configuration error behaviour */ } fclose(fp); NCONF_free(cnf); } .Ve

"SEE ALSO"
Header "SEE ALSO" \fBconfig\|(5), \fBOPENSSL_config\|(3), \fBNCONF_new_ex\|(3)
"COPYRIGHT"
Header "COPYRIGHT" Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.