![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS
int
int
const char *
DESCRIPTIONThe function
See the EXAMPLES section for additional functions that may need to be called. Calling configuration functions in the right order for the intended effect can be tricky because many configuration functions internally call each other.
The following flags are currently recognized:
By using
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 may continue. In other cases an application might consider a configuration file error fatal and exit immediately. Applications can use the
RETURN VALUES
FILES
EXAMPLESLoad a configuration file and print out any errors and exit (missing file considered fatal): if (CONF_modules_load_file(NULL, NULL, 0) <= 0) { fprintf(stderr, "FATAL: error loading configuration file\n"); ERR_print_errors_fp(stderr); exit(1); } Load default configuration file using the section indicated by "myapp", tolerate missing files, but exit on other errors: if (CONF_modules_load_file(NULL, "myapp", CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) { fprintf(stderr, "FATAL: error loading configuration file\n"); ERR_print_errors_fp(stderr); exit(1); } Load custom configuration file and section instead of the standard one, only print warnings on error, missing configuration file ignored: OPENSSL_no_config(); OPENSSL_load_builtin_modules(); if (CONF_modules_load_file("/something/app.cnf", "myapp", CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) { fprintf(stderr, "WARNING: error loading configuration file\n"); ERR_print_errors_fp(stderr); } In the previous example, the call to OPENSSL_no_config(3) is required first to suppress automatic loading of the standard configuration file, and the call to OPENSSL_load_builtin_modules(3) is needed so that the configuration of builtin modules is loaded in addition to the configuration of "myapp". Load and parse configuration file manually, custom error handling: FILE *fp; CONF *cnf = NULL; long eline; fp = fopen("/somepath/app.cnf", "r"); if (fp == NULL) { fprintf(stderr, "Error opening configuration file\n"); /* 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\n", 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\n"); ERR_print_errors_fp(stderr); /* Other configuration error behaviour */ } fclose(fp); NCONF_free(cnf); } SEE ALSOCONF_modules_free(3), ERR(3), OPENSSL_config(3), OPENSSL_load_builtin_modules(3) HISTORY
|