1CONF_modules_load_file(3)           OpenSSL          CONF_modules_load_file(3)
2
3
4

NAME

6        CONF_modules_load_file, CONF_modules_load - OpenSSL configuration functions
7

SYNOPSIS

9        #include <openssl/conf.h>
10
11        int CONF_modules_load_file(const char *filename, const char *appname,
12                                               unsigned long flags);
13        int CONF_modules_load(const CONF *cnf, const char *appname,
14                                      unsigned long flags);
15

DESCRIPTION

17       The function CONF_modules_load_file() configures OpenSSL using file
18       filename and application name appname. If filename is NULL the standard
19       OpenSSL configuration file is used. If appname is NULL the standard
20       OpenSSL application name openssl_conf is used.  The behaviour can be
21       cutomized using flags.
22
23       CONF_modules_load() is idential to CONF_modules_load_file() except it
24       reads configuration information from cnf.
25

NOTES

27       The following flags are currently recognized:
28
29       CONF_MFLAGS_IGNORE_ERRORS if set errors returned by individual
30       configuration modules are ignored. If not set the first module error is
31       considered fatal and no further modules are loaded.
32
33       Normally any modules errors will add error information to the error
34       queue. If CONF_MFLAGS_SILENT is set no error information is added.
35
36       If CONF_MFLAGS_NO_DSO is set configuration module loading from DSOs is
37       disabled.
38
39       CONF_MFLAGS_IGNORE_MISSING_FILE if set will make
40       CONF_load_modules_file() ignore missing configuration files. Normally a
41       missing configuration file return an error.
42
43       CONF_MFLAGS_DEFAULT_SECTION if set and appname is not NULL will use the
44       default section pointed to by openssl_conf if appname does not exist.
45
46       Applications should call these functions after loading builtin modules
47       using OPENSSL_load_builtin_modules(), any ENGINEs for example using
48       ENGINE_load_builtin_engines(), any algorithms for example
49       OPENSSL_add_all_algorithms() and (if the application uses libssl)
50       SSL_library_init().
51
52       By using CONF_modules_load_file() with appropriate flags an application
53       can customise application configuration to best suit its needs. In some
54       cases the use of a configuration file is optional and its absence is
55       not an error: in this case CONF_MFLAGS_IGNORE_MISSING_FILE would be
56       set.
57
58       Errors during configuration may also be handled differently by
59       different applications. For example in some cases an error may simply
60       print out a warning message and the application continue. In other
61       cases an application might consider a configuration file error as fatal
62       and exit immediately.
63
64       Applications can use the CONF_modules_load() function if they wish to
65       load a configuration file themselves and have finer control over how
66       errors are treated.
67

EXAMPLES

69       Load a configuration file and print out any errors and exit (missing
70       file considered fatal):
71
72        if (CONF_modules_load_file(NULL, NULL, 0) <= 0) {
73           fprintf(stderr, "FATAL: error loading configuration file\n");
74           ERR_print_errors_fp(stderr);
75           exit(1);
76        }
77
78       Load default configuration file using the section indicated by "myapp",
79       tolerate missing files, but exit on other errors:
80
81        if (CONF_modules_load_file(NULL, "myapp",
82                                   CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
83           fprintf(stderr, "FATAL: error loading configuration file\n");
84           ERR_print_errors_fp(stderr);
85           exit(1);
86        }
87
88       Load custom configuration file and section, only print warnings on
89       error, missing configuration file ignored:
90
91        if (CONF_modules_load_file("/something/app.cnf", "myapp",
92                                   CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
93           fprintf(stderr, "WARNING: error loading configuration file\n");
94           ERR_print_errors_fp(stderr);
95        }
96
97       Load and parse configuration file manually, custom error handling:
98
99        FILE *fp;
100        CONF *cnf = NULL;
101        long eline;
102        fp = fopen("/somepath/app.cnf", "r");
103        if (fp == NULL) {
104           fprintf(stderr, "Error opening configuration file\n");
105           /* Other missing configuration file behaviour */
106        } else {
107           cnf = NCONF_new(NULL);
108           if (NCONF_load_fp(cnf, fp, &eline) == 0) {
109               fprintf(stderr, "Error on line %ld of configuration file\n", eline);
110               ERR_print_errors_fp(stderr);
111               /* Other malformed configuration file behaviour */
112           } else if (CONF_modules_load(cnf, "appname", 0) <= 0) {
113             fprintf(stderr, "Error configuring application\n");
114             ERR_print_errors_fp(stderr);
115             /* Other configuration error behaviour */
116           }
117           fclose(fp);
118           NCONF_free(cnf);
119         }
120

RETURN VALUES

122       These functions return 1 for success and a zero or negative value for
123       failure. If module errors are not ignored the return code will reflect
124       the return value of the failing module (this will always be zero or
125       negative).
126

SEE ALSO

128       conf(5), OPENSSL_config(3), CONF_free(3), err(3)
129

HISTORY

131       CONF_modules_load_file and CONF_modules_load first appeared in OpenSSL
132       0.9.7.
133
134
135
1361.0.2o                            2018-03-27         CONF_modules_load_file(3)
Impressum