xref: /freebsd/secure/lib/libcrypto/man/man3/CONF_modules_load_file.3 (revision 5abaf0866445a61c11665fffc148ecd13a7bb9ac)
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-02-07" "1.1.1t" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
CONF_modules_load_file, CONF_modules_load - OpenSSL configuration functions
"SYNOPSIS"
Header "SYNOPSIS" .Vb 1 #include <openssl/conf.h> \& 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_modules_load_file() configures OpenSSL using file \fBfilename and application name appname. If filename is \s-1NULL\s0 the standard OpenSSL configuration file is used. If appname is \s-1NULL\s0 the standard OpenSSL application name openssl_conf is used. The behaviour can be customized using flags.

\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 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() 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(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(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("/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(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), OPENSSL_config\|(3)
"COPYRIGHT"
Header "COPYRIGHT" Copyright 2004-2019 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the OpenSSL license (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>.