CONF_modules_load_file(3) OpenSSL CONF_modules_load_file(3) NNAAMMEE CONF_modules_load_file, CONF_modules_load - OpenSSL configuration functions SSYYNNOOPPSSIISS #include 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); DDEESSCCRRIIPPTTIIOONN The function _C_O_N_F___m_o_d_u_l_e_s___l_o_a_d___f_i_l_e_(_) configures OpenSSL using file ffiilleennaammee and application name aappppnnaammee. If ffiilleennaammee is NULL the standard OpenSSL configuration file is used. If aappppnnaammee is NULL the standard OpenSSL application name ooppeennssssll__ccoonnff is used. The behaviour can be cutomized using ffllaaggss. _C_O_N_F___m_o_d_u_l_e_s___l_o_a_d_(_) is idential to _C_O_N_F___m_o_d_u_l_e_s___l_o_a_d___f_i_l_e_(_) except it reads configuration information from ccnnff. NNOOTTEESS The following ffllaaggss are currently recognized: CCOONNFF__MMFFLLAAGGSS__IIGGNNOORREE__EERRRROORRSS if set errors returned by individual configu- ration modules are ignored. If not set the first module error is con- sidered fatal and no further modules are loaded. Normally any modules errors will add error information to the error queue. If CCOONNFF__MMFFLLAAGGSS__SSIILLEENNTT is set no error information is added. If CCOONNFF__MMFFLLAAGGSS__NNOO__DDSSOO is set configuration module loading from DSOs is disabled. CCOONNFF__MMFFLLAAGGSS__IIGGNNOORREE__MMIISSSSIINNGG__FFIILLEE if set will make _C_O_N_F___l_o_a_d___m_o_d_- _u_l_e_s___f_i_l_e_(_) ignore missing configuration files. Normally a missing con- figuration file return an error. CCOONNFF__MMFFLLAAGGSS__DDEEFFAAUULLTT__SSEECCTTIIOONN if set and aappppnnaammee is not NULL will use the default section pointed to by ooppeennssssll__ccoonnff if aappppnnaammee does not exist. Applications should call these functions after loading builtin modules using _O_P_E_N_S_S_L___l_o_a_d___b_u_i_l_t_i_n___m_o_d_u_l_e_s_(_), any ENGINEs for example using _E_N_G_I_N_E___l_o_a_d___b_u_i_l_t_i_n___e_n_g_i_n_e_s_(_), any algorithms for example _O_P_E_N_S_S_L___a_d_d___a_l_l___a_l_g_o_r_i_t_h_m_s_(_) and (if the application uses libssl) _S_S_L___l_i_b_r_a_r_y___i_n_i_t_(_). By using _C_O_N_F___m_o_d_u_l_e_s___l_o_a_d___f_i_l_e_(_) 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 CCOONNFF__MMFFLLAAGGSS__IIGGNNOORREE__MMIISSSSIINNGG__FFIILLEE would be set. Errors during configuration may also be handled differently by differ- ent 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 _C_O_N_F___m_o_d_u_l_e_s___l_o_a_d_(_) function if they wish to load a configuration file themselves and have finer control over how errors are treated. EEXXAAMMPPLLEESS Load 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, only print warnings on error, missing configuration file ignored: 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); } 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); } RREETTUURRNN VVAALLUUEESS 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). SSEEEE AALLSSOO _c_o_n_f(5), _O_P_E_N_S_S_L___c_o_n_f_i_g(3), _C_O_N_F___f_r_e_e(3), _e_r_r(3) HHIISSTTOORRYY CONF_modules_load_file and CONF_modules_load first appeared in OpenSSL 0.9.7. 1.0.1u 2016-09-22 CONF_modules_load_file(3)